pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix use-after-free in pg_show_all_settings().
2+ messages / 1 participants
[nested] [flat]

* pgsql: Fix use-after-free in pg_show_all_settings().
@ 2026-11-09 14:21 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 2+ messages in thread

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

Fix use-after-free in pg_show_all_settings().

Commit 3057465acfbe changed show_all_settings(), used by the
pg_show_all_settings() SQL function, to collect pointers to all GUC
entries on its first call and return one row per call from that saved
array.  When a module is loaded while the scan is still in progress,
the placeholder entries for that module's prefix are replaced and
freed, while the saved array keeps pointing at them.  That caused a
use-after-free.  Depending on what reused the freed chunk, the scan
returns stale rows or the backend crashes.

Fix this by using the materialize mode for show_all_settings() so that
the GUC array is consumed before any other expression in the query can
run and free an entry.  This is also how the sibling function
show_all_file_settings() already works.  We only have a few hundred
GUCs in practice, so materializing them all is acceptable.

Backpatch to v16, where that commit first appeared.  On v15 and
earlier show_all_settings() reads each GUC entry by number on every
call and never keeps a pointer across calls, so it is not affected.

Reported-by: Stephan Lipp <Stephan@Adalogics.com>
Reviewed-by: Greg Burd <greg@burd.me>
Backpatch-through: 16
Security: CVE-2026-120152

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/146771107cf1ca5ea33ceb9e1d1bf60eb8a24987
Author: Masahiko Sawada <msawada@postgresql.org>

Modified Files
--------------
src/backend/utils/misc/guc_funcs.c | 120 ++++++++-----------------------------
1 file changed, 24 insertions(+), 96 deletions(-)



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

* pgsql: Fix use-after-free in pg_show_all_settings().
@ 2026-11-09 14:21 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 2+ messages in thread

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

Fix use-after-free in pg_show_all_settings().

Commit 3057465acfbe changed show_all_settings(), used by the
pg_show_all_settings() SQL function, to collect pointers to all GUC
entries on its first call and return one row per call from that saved
array.  When a module is loaded while the scan is still in progress,
the placeholder entries for that module's prefix are replaced and
freed, while the saved array keeps pointing at them.  That caused a
use-after-free.  Depending on what reused the freed chunk, the scan
returns stale rows or the backend crashes.

Fix this by using the materialize mode for show_all_settings() so that
the GUC array is consumed before any other expression in the query can
run and free an entry.  This is also how the sibling function
show_all_file_settings() already works.  We only have a few hundred
GUCs in practice, so materializing them all is acceptable.

Backpatch to v16, where that commit first appeared.  On v15 and
earlier show_all_settings() reads each GUC entry by number on every
call and never keeps a pointer across calls, so it is not affected.

Reported-by: Stephan Lipp <Stephan@Adalogics.com>
Reviewed-by: Greg Burd <greg@burd.me>
Backpatch-through: 16
Security: CVE-2026-120152

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/369fe93c0558acb25fa51761d697ae38047c1b40
Author: Masahiko Sawada <msawada@postgresql.org>

Modified Files
--------------
src/backend/utils/misc/guc_funcs.c | 120 ++++++++-----------------------------
1 file changed, 24 insertions(+), 96 deletions(-)



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


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

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09 14:21 pgsql: Fix use-after-free in pg_show_all_settings(). Noah Misch <noah@leadboat.com>
2026-11-09 14:21 pgsql: Fix use-after-free in pg_show_all_settings(). 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