pgsql: find_or_make_matching_shared_tupledesc: Fix possible use-after-f

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: find_or_make_matching_shared_tupledesc: Fix possible use-after-f
Date: 2026-11-09 14:21:53
Message-ID: E1xQQFt-000000003R6-0aVD@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

find_or_make_matching_shared_tupledesc: Fix possible use-after-free.

Previously, the following sequence of events was possible: (1) new
anonymous-record typmod gets entered into shared_typmod_table;
(2) another process resolves the typmod and stores a pointer to the
associated TupleDesc; (3) the first process realizes that the
TupleDesc duplicates one that already has some other typmod assigned
to it and frees the TupleDesc; (4) later, the other process
accesses the now-freed storage, interprets it as a TupleDesc, and
uses it to deform a tuple.

It is likely that an attacker can control the new contents of the
freed memory to a sufficient degree to achieve arbitrary code
execution; hence, this is a security vulnerability.

Reported-by: Peter Geoghegan <pg(at)bowt(dot)ie>
Reviewed-by: Andrew Dunstan <andrew(at)dunslane(dot)net>
Security: CVE-2026-116304
Backpatch-through: 14

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4285796c2738c1500f60b169f4c43a695fefee77
Author: Robert Haas <rhaas(at)postgresql(dot)org>

Modified Files
--------------
src/backend/utils/cache/typcache.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2026-11-09 14:21:54 pgsql: Fix use-after-free in pg_show_all_settings().
Previous Message Noah Misch 2026-11-09 14:21:52 pgsql: Avoid use-after-free hazards in re-entrant use of pltcl.