pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Dispatch pre-auth cancel requests until _exit(1) handlers are di
3+ messages / 1 participants
[nested] [flat]

* pgsql: Dispatch pre-auth cancel requests until _exit(1) handlers are di
@ 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

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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/208ea05a51b8e2116323054aa5110f66803a010d
Author: Michael Paquier <michael@paquier.xyz>

Modified Files
--------------
src/backend/tcop/backend_startup.c | 52 +++++++++++++++++++++++++++++---------
src/tools/pgindent/typedefs.list   |  1 +
2 files changed, 41 insertions(+), 12 deletions(-)



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

* pgsql: Dispatch pre-auth cancel requests until _exit(1) handlers are di
@ 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

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_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f63b47aa18e6b9b205f51b74d7d5dffe010e8255
Author: Michael Paquier <michael@paquier.xyz>

Modified Files
--------------
src/backend/tcop/backend_startup.c | 52 +++++++++++++++++++++++++++++---------
src/tools/pgindent/typedefs.list   |  1 +
2 files changed, 41 insertions(+), 12 deletions(-)



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

* pgsql: Dispatch pre-auth cancel requests until _exit(1) handlers are di
@ 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

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(-)



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


end of thread, other threads:[~2026-11-09 14:21 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: Dispatch pre-auth cancel requests until _exit(1) handlers are di Noah Misch <noah@leadboat.com>
2026-11-09 14:21 pgsql: Dispatch pre-auth cancel requests until _exit(1) handlers are di Noah Misch <noah@leadboat.com>
2026-11-09 14:21 pgsql: Dispatch pre-auth cancel requests until _exit(1) handlers are di 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