pgsql: Fix crash in REINDEX CONCURRENTLY due to DDLs run in index funct

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix crash in REINDEX CONCURRENTLY due to DDLs run in index funct
Date: 2026-11-09 14:21:53
Message-ID: E1xQQFt-000000003Rj-1uDe@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix crash in REINDEX CONCURRENTLY due to DDLs run in index functions

ReindexRelationConcurrently() keeps track of the OIDs of the relations
it processes across all its phases, relying on session locks to protect
them. A function called from an index predicate or expression could
drop one of the indexes being processed by a REINDEX CONCURRENTLY,
causing a crash during the swap phase due to a relation gone missing.

The relations being reindexed, on which are taken the session locks, are
now pinned during the build and validation phases so as no manipulation
of their definition can happen in the session running a REINDEX
CONCURRENTLY.

Reported-by: Florent Saudel <fsaudel(at)protonmail(dot)com>
Author: Michael Paquier <michael(at)paquier(dot)xyz>
Backpatch-through: 14
Security: CVE-2026-116336

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f3eba64926fd7c43639801adbf8ff8051b82ba8a
Author: Michael Paquier <michael(at)paquier(dot)xyz>

Modified Files
--------------
src/backend/commands/indexcmds.c | 62 ++++++++++++++++++++++++++++++
src/test/regress/expected/create_index.out | 27 +++++++++++++
src/test/regress/sql/create_index.sql | 21 ++++++++++
3 files changed, 110 insertions(+)

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.