From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix use-after-free bug with event triggers in an extension scrip
Date: Wed, 16 Sep 2020 00:05:09 +0000
Message-ID: <E1kIKwf-00087s-6H@gemulon.postgresql.org> (raw)
Fix use-after-free bug with event triggers in an extension script
ALTER TABLE commands in an extension script are added to an event
trigger command list; but starting with commit b5810de3f4 they do so in
a memory context that's too short-lived, so when execution ends and time
comes to use the entries, they've already been freed.
(This would also be a problem with ALTER TABLE commands in a
multi-command query string, but these serendipitously end in
PortalContext -- which probably explains why it took so long for this to
be reported.)
Fix by using the memory context specifically set for that, instead.
Backpatch to 13, where the aforementioned commit appeared.
Reported-by: Philippe Beaudoin
Author: Jehan-Guillaume de Rorthais <jgdr@dalibo.com>
Discussion: https://postgr.es/m/20200902193715.6e0269d4@firost
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/ced138e8cbac7f5a840de8679e9882665478c680
Modified Files
--------------
src/backend/commands/event_trigger.c | 6 ++++++
src/test/modules/test_extensions/Makefile | 6 ++++--
.../modules/test_extensions/expected/test_extensions.out | 5 +++++
src/test/modules/test_extensions/sql/test_extensions.sql | 6 ++++++
.../test_extensions/test_ext_evttrig--1.0--2.0.sql | 7 +++++++
.../modules/test_extensions/test_ext_evttrig--1.0.sql | 16 ++++++++++++++++
.../modules/test_extensions/test_ext_evttrig.control | 3 +++
7 files changed, 47 insertions(+), 2 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: alvherre@alvh.no-ip.org
Subject: Re: pgsql: Fix use-after-free bug with event triggers in an extension scrip
In-Reply-To: <E1kIKwf-00087s-6H@gemulon.postgresql.org>
References: <E1kIKwf-00087s-6H@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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