pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix oversight in handling of modifiedCols since f24523672d 5+ messages / 1 participants [nested] [flat]
* pgsql: Fix oversight in handling of modifiedCols since f24523672d @ 2023-07-02 20:22 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 5+ messages in thread From: Tomas Vondra @ 2023-07-02 20:22 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix oversight in handling of modifiedCols since f24523672d Commit f24523672d fixed a memory leak by moving the modifiedCols bitmap into the per-row memory context. In the case of AFTER UPDATE triggers, the bitmap is however referenced from an event kept until the end of the query, resulting in a use-after-free bug. Fixed by copying the bitmap into the AfterTriggerEvents memory context, which is the one where we keep the trigger events. There's only one place that needs to do the copy, but the memory context may not exist yet. Doing that in a separate function seems more readable. Report by Alexander Pyhalov, fix by me. Backpatch to 13, where the bitmap was added to the event by commit 71d60e2aa0. Reported-by: Alexander Pyhalov Backpatch-through: 13 Discussion: https://postgr.es/m/acddb17c89b0d6cb940eaeda18c08bbe@postgrespro.ru Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/ce5aaea8cd32b88451914356989f0f4ecb9e4482 Modified Files -------------- src/backend/commands/trigger.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix oversight in handling of modifiedCols since f24523672d @ 2023-07-02 20:22 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 5+ messages in thread From: Tomas Vondra @ 2023-07-02 20:22 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix oversight in handling of modifiedCols since f24523672d Commit f24523672d fixed a memory leak by moving the modifiedCols bitmap into the per-row memory context. In the case of AFTER UPDATE triggers, the bitmap is however referenced from an event kept until the end of the query, resulting in a use-after-free bug. Fixed by copying the bitmap into the AfterTriggerEvents memory context, which is the one where we keep the trigger events. There's only one place that needs to do the copy, but the memory context may not exist yet. Doing that in a separate function seems more readable. Report by Alexander Pyhalov, fix by me. Backpatch to 13, where the bitmap was added to the event by commit 71d60e2aa0. Reported-by: Alexander Pyhalov Backpatch-through: 13 Discussion: https://postgr.es/m/acddb17c89b0d6cb940eaeda18c08bbe@postgrespro.ru Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9cf85093b55979e7d8ccfd9d0da21ce277a2f321 Modified Files -------------- src/backend/commands/trigger.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix oversight in handling of modifiedCols since f24523672d @ 2023-07-02 20:22 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 5+ messages in thread From: Tomas Vondra @ 2023-07-02 20:22 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix oversight in handling of modifiedCols since f24523672d Commit f24523672d fixed a memory leak by moving the modifiedCols bitmap into the per-row memory context. In the case of AFTER UPDATE triggers, the bitmap is however referenced from an event kept until the end of the query, resulting in a use-after-free bug. Fixed by copying the bitmap into the AfterTriggerEvents memory context, which is the one where we keep the trigger events. There's only one place that needs to do the copy, but the memory context may not exist yet. Doing that in a separate function seems more readable. Report by Alexander Pyhalov, fix by me. Backpatch to 13, where the bitmap was added to the event by commit 71d60e2aa0. Reported-by: Alexander Pyhalov Backpatch-through: 13 Discussion: https://postgr.es/m/acddb17c89b0d6cb940eaeda18c08bbe@postgrespro.ru Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/7ae4e786892f45af4ded23c94a26537a4b11a4c7 Modified Files -------------- src/backend/commands/trigger.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix oversight in handling of modifiedCols since f24523672d @ 2023-07-02 20:23 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 5+ messages in thread From: Tomas Vondra @ 2023-07-02 20:23 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix oversight in handling of modifiedCols since f24523672d Commit f24523672d fixed a memory leak by moving the modifiedCols bitmap into the per-row memory context. In the case of AFTER UPDATE triggers, the bitmap is however referenced from an event kept until the end of the query, resulting in a use-after-free bug. Fixed by copying the bitmap into the AfterTriggerEvents memory context, which is the one where we keep the trigger events. There's only one place that needs to do the copy, but the memory context may not exist yet. Doing that in a separate function seems more readable. Report by Alexander Pyhalov, fix by me. Backpatch to 13, where the bitmap was added to the event by commit 71d60e2aa0. Reported-by: Alexander Pyhalov Backpatch-through: 13 Discussion: https://postgr.es/m/acddb17c89b0d6cb940eaeda18c08bbe@postgrespro.ru Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/260dbf19a5b4269feb6d29887aed94454602d8ac Modified Files -------------- src/backend/commands/trigger.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix oversight in handling of modifiedCols since f24523672d @ 2023-07-02 20:23 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 5+ messages in thread From: Tomas Vondra @ 2023-07-02 20:23 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix oversight in handling of modifiedCols since f24523672d Commit f24523672d fixed a memory leak by moving the modifiedCols bitmap into the per-row memory context. In the case of AFTER UPDATE triggers, the bitmap is however referenced from an event kept until the end of the query, resulting in a use-after-free bug. Fixed by copying the bitmap into the AfterTriggerEvents memory context, which is the one where we keep the trigger events. There's only one place that needs to do the copy, but the memory context may not exist yet. Doing that in a separate function seems more readable. Report by Alexander Pyhalov, fix by me. Backpatch to 13, where the bitmap was added to the event by commit 71d60e2aa0. Reported-by: Alexander Pyhalov Backpatch-through: 13 Discussion: https://postgr.es/m/acddb17c89b0d6cb940eaeda18c08bbe@postgrespro.ru Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/984c23f6f5926f7cfb304b8f931e9bb66174b41c Modified Files -------------- src/backend/commands/trigger.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2023-07-02 20:23 UTC | newest] Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-07-02 20:22 pgsql: Fix oversight in handling of modifiedCols since f24523672d Tomas Vondra <tomas.vondra@postgresql.org> 2023-07-02 20:22 pgsql: Fix oversight in handling of modifiedCols since f24523672d Tomas Vondra <tomas.vondra@postgresql.org> 2023-07-02 20:22 pgsql: Fix oversight in handling of modifiedCols since f24523672d Tomas Vondra <tomas.vondra@postgresql.org> 2023-07-02 20:23 pgsql: Fix oversight in handling of modifiedCols since f24523672d Tomas Vondra <tomas.vondra@postgresql.org> 2023-07-02 20:23 pgsql: Fix oversight in handling of modifiedCols since f24523672d Tomas Vondra <tomas.vondra@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox