From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Dispatch pre-auth cancel requests until _exit(1) handlers are di
Date: Mon, 09 Nov 2026 14:21:57 +0000
Message-ID: <E1xQQFx-000000003bq-3QJ5@gemulon.postgresql.org> (raw)
Dispatch pre-auth cancel requests until _exit(1) handlers are disarmed
BackendInitialize() collects the startup packet with two facilities able
to exit() early:
- StartupPacketTimeoutHandler(), timeout enabled for the startup
process, via StartupPacketTimeoutHandler()
- process_startup_packet_die(), for SIGTERM
Both assume that shared memory is never touched, meaning that a hard
exit() is fine, as no cleanup action need to be taken.
9d9b9d46f3c5 broke this assumption by making the cancel request handling
happen earlier in the pre-authentication process: SendCancelRequest()
can acquire the spinlock "pss_mutex" to compare cancel keys. If SIGALRM
(authentication_timeout) or SIGTERM is received while "pss_mutex" is
acquired, the process would exit with a spinlock still held. The next
process touching the same proc slot as the one that has exited earlier
would wait indefinitely for the spin lock, crashing the server on PANIC
after one minute of wait.
This commit changes the cancel request handling so as a request received
is stashed instead of immediately processed. Its processing is delayed
once it is safe to do so, where the startup timeout and SIGTERM handler
are cleared.
Reported-by: Anthropic OSS program
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Backpatch-through: 18
Security: CVE-2026-116322
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/e1cc4a89318d919d3875443fd63704634aad21d4
Author: Michael Paquier <michael@paquier.xyz>
Modified Files
--------------
src/backend/tcop/backend_startup.c | 54 +++++++++++++++++++++++++++++---------
src/tools/pgindent/typedefs.list | 1 +
2 files changed, 43 insertions(+), 12 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: noah@leadboat.com
Subject: Re: pgsql: Dispatch pre-auth cancel requests until _exit(1) handlers are di
In-Reply-To: <E1xQQFx-000000003bq-3QJ5@gemulon.postgresql.org>
References: <E1xQQFx-000000003bq-3QJ5@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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