| From: | Noah Misch <noah(at)leadboat(dot)com> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Handle composite type changes in ExecEvalFieldStore[De]Form |
| Date: | 2026-11-09 14:21:53 |
| Message-ID: | E1xQQFt-000000003Qq-03ZA@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Handle composite type changes in ExecEvalFieldStore[De]Form
The composite type may be modified during execution, e.g. between
deforming and forming a value, but the executor code ignored that and
could have deformed/formed the tuple with a mismatching descriptor. The
consequences could be severe, including reading/writing memory, etc.
Fixed by remembering the descriptor in ExecInitExprRec(), and using it
when deforming and forming tuples later, instead of looking up a new
descriptor. This is the same approach already used for RowExpr.
This means attributes added after initializing the descriptor will be
treated as NULL, and dropped attributes will be removed from the tuple.
Technically, this is an ABI break. It modifies the ExprEvalStep, which
is part of the ABI. The meaning of one pointer (replacing rowcache with
tupdesc) changes, and ncolumns gets removed. Neither changes the layout
or size of the struct, and so should be backwards compatible. It could
have a bigger impact on custom JIT providers, but we've not found any.
Reported-by: OpenAI Codex Security
Reported-by: Bronson Yen <bronson(at)calif(dot)io>
Reported-by: Mehmet D. INCE <mehmet(at)mehmetince(dot)net>
Author: Tomas Vondra <tomas(at)vondra(dot)me>
Co-Authored-by: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
Reviewed-by: Andres Freund <andres(at)anarazel(dot)de>
Security: CVE-2026-116306
Backpatch-through: 14
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/2ac7e6e8a56587e8976b1ebb3c8cf9e1de98346d
Author: Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org>
Modified Files
--------------
src/backend/executor/execExpr.c | 31 +++++---
src/backend/executor/execExprInterp.c | 26 +------
src/include/executor/execExpr.h | 5 +-
src/test/regress/expected/rowtypes.out | 132 +++++++++++++++++++++++++++++++++
src/test/regress/sql/rowtypes.sql | 131 ++++++++++++++++++++++++++++++++
5 files changed, 286 insertions(+), 39 deletions(-)
| 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. |