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 <[email protected]>
Reviewed-by: Andrew Dunstan <[email protected]>
Security: CVE-2026-116304
Backpatch-through: 14

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4285796c2738c1500f60b169f4c43a695fefee77
Author: Robert Haas <[email protected]>

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

Reply via email to