pgsql: Avoid using a dangling pointer in expanded-record domain checks.

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid using a dangling pointer in expanded-record domain checks.
Date: 2026-11-09 14:21:51
Message-ID: E1xQQFr-000000003MG-02Jd@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid using a dangling pointer in expanded-record domain checks.

build_dummy_expanded_header() sets up the expanded record's dummy
child to have eoh_context equal to the parent's er_short_term_cxt.
If some operation on the dummy record causes creation of a short-term
context belonging to the dummy record itself, that will be a child
of the parent's er_short_term_cxt, which means it will get deleted
when we reset the parent's er_short_term_cxt at the end of the callers
of build_dummy_expanded_header(). So the next time through, we'll try
to use a dangling context pointer, which often will now be pointing
at some other unrelated context. That at least risks a crash, and
it's reported to be exploitable for arbitrary code execution.
To fix, just clear the potentially-dangling pointer in the next
usage cycle.

Reported-by: Claude and Ada Logics
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Backpatch-through: 14
Security: CVE-2026-120150

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b93d8a554da5d9da56dab632b54d31dd05beea49
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>

Modified Files
--------------
src/backend/utils/adt/expandedrecord.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2026-11-09 14:21:52 pgsql: Avoid use-after-free hazards in re-entrant use of pltcl.
Previous Message Noah Misch 2026-11-09 14:21:50 pgsql: Teach equalRowTypes() to safely handle dropped columns.