pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Teach equalRowTypes() to safely handle dropped columns.
3+ messages / 1 participants
[nested] [flat]

* pgsql: Teach equalRowTypes() to safely handle dropped columns.
@ 2026-11-09 14:21  Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Teach equalRowTypes() to safely handle dropped columns.

equalRowTypes compared the name, type, typmod, and collation of
corresponding attributes.  That's sufficient when neither attribute has
been dropped, since their physical storage attributes (attlen and
attalign) are derived from their type.  But a dropped attribute has its
atttypid set to InvalidOid while keeping the attlen and attalign of the
type that the column used to have.  Two row types that merely had
dropped attributes in the same positions could therefore be considered
equal, even when the dropped attributes' widths or alignments differed.

That was a problem for typcache.c's record type cache, which relies on
equalRowTypes to decide whether a tuple descriptor matches one that was
already assigned a record typmod.  A tuple built using one tuple
descriptor could be assigned the typmod of a physically incompatible
descriptor, allowing it to be deformed using that descriptor.  That
could be abused to make the server disclose memory contents, and to
achieve arbitrary code execution.

To fix, make equalRowTypes also compare the attlen and attalign of
corresponding dropped attributes.

Oversight in commit 20e58105, which introduced equalRowTypes.
equalTupleDescs already compared attlen and attalign, but equalRowTypes
missed that precedent.

Reported-by: Peter Geoghegan <pg@bowt.ie>
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Security: CVE-2026-120142
Backpatch-through: 17

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c2439a04353ccab618006f21df8698aa9cc31167
Author: Peter Geoghegan <pg@bowt.ie>

Modified Files
--------------
src/backend/access/common/tupdesc.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Teach equalRowTypes() to safely handle dropped columns.
@ 2026-11-09 14:21  Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Teach equalRowTypes() to safely handle dropped columns.

equalRowTypes compared the name, type, typmod, and collation of
corresponding attributes.  That's sufficient when neither attribute has
been dropped, since their physical storage attributes (attlen and
attalign) are derived from their type.  But a dropped attribute has its
atttypid set to InvalidOid while keeping the attlen and attalign of the
type that the column used to have.  Two row types that merely had
dropped attributes in the same positions could therefore be considered
equal, even when the dropped attributes' widths or alignments differed.

That was a problem for typcache.c's record type cache, which relies on
equalRowTypes to decide whether a tuple descriptor matches one that was
already assigned a record typmod.  A tuple built using one tuple
descriptor could be assigned the typmod of a physically incompatible
descriptor, allowing it to be deformed using that descriptor.  That
could be abused to make the server disclose memory contents, and to
achieve arbitrary code execution.

To fix, make equalRowTypes also compare the attlen and attalign of
corresponding dropped attributes.

Oversight in commit 20e58105, which introduced equalRowTypes.
equalTupleDescs already compared attlen and attalign, but equalRowTypes
missed that precedent.

Reported-by: Peter Geoghegan <pg@bowt.ie>
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Security: CVE-2026-120142
Backpatch-through: 17

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/c9f334488a29e91c43f6879fd7c563ae94ff640b
Author: Peter Geoghegan <pg@bowt.ie>

Modified Files
--------------
src/backend/access/common/tupdesc.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Teach equalRowTypes() to safely handle dropped columns.
@ 2026-11-09 14:22  Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Noah Misch @ 2026-11-09 14:22 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Teach equalRowTypes() to safely handle dropped columns.

equalRowTypes compared the name, type, typmod, and collation of
corresponding attributes.  That's sufficient when neither attribute has
been dropped, since their physical storage attributes (attlen and
attalign) are derived from their type.  But a dropped attribute has its
atttypid set to InvalidOid while keeping the attlen and attalign of the
type that the column used to have.  Two row types that merely had
dropped attributes in the same positions could therefore be considered
equal, even when the dropped attributes' widths or alignments differed.

That was a problem for typcache.c's record type cache, which relies on
equalRowTypes to decide whether a tuple descriptor matches one that was
already assigned a record typmod.  A tuple built using one tuple
descriptor could be assigned the typmod of a physically incompatible
descriptor, allowing it to be deformed using that descriptor.  That
could be abused to make the server disclose memory contents, and to
achieve arbitrary code execution.

To fix, make equalRowTypes also compare the attlen and attalign of
corresponding dropped attributes.

Oversight in commit 20e58105, which introduced equalRowTypes.
equalTupleDescs already compared attlen and attalign, but equalRowTypes
missed that precedent.

Reported-by: Peter Geoghegan <pg@bowt.ie>
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Security: CVE-2026-120142
Backpatch-through: 17

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/35d851811f9f2ebb8d88baa27964bce8fb98ef40
Author: Peter Geoghegan <pg@bowt.ie>

Modified Files
--------------
src/backend/access/common/tupdesc.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-11-09 14:22 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09 14:21 pgsql: Teach equalRowTypes() to safely handle dropped columns. Noah Misch <noah@leadboat.com>
2026-11-09 14:21 pgsql: Teach equalRowTypes() to safely handle dropped columns. Noah Misch <noah@leadboat.com>
2026-11-09 14:22 pgsql: Teach equalRowTypes() to safely handle dropped columns. Noah Misch <noah@leadboat.com>

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