Re: Use-after-free in 12- EventTriggerAlterTableEnd

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Arseny Sher <a(dot)sher(at)postgrespro(dot)ru>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Subject: Re: Use-after-free in 12- EventTriggerAlterTableEnd
Date: 2020-10-27 19:21:07
Message-ID: 1093133.1603826467@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Arseny Sher <a(dot)sher(at)postgrespro(dot)ru> writes:
> Valgrind on our internal buildfarm complained about use-after-free
> during currentEventTriggerState->commandList manipulations, e.g. lappend
> in EventTriggerCollectSimpleCommand. I've discovered that the source of
> problem is EventTriggerAlterTableEnd not bothering to switch into its
> own context before appending to the list. ced138e8cba fixed this in
> master and 13 but wasn't backpatched further, so I see the problem in
> 12-.

Yeah, that clearly should have been back-patched --- the fact that it
accidentally didn't fail in the most common case wasn't a good reason
for leaving the bug in place. I'm not excited about the test case
ced138e8cba added though, so I think your proposed patch is fine.
Will push shortly.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2020-10-27 19:24:35 cutting down the TODO list thread
Previous Message Anastasia Lubennikova 2020-10-27 19:16:11 Re: COPY FREEZE and setting PD_ALL_VISIBLE/visibility map bits