Re: Using WaitEventSet in the postmaster
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2023-01-12T18:26:29Z
Lists: pgsql-hackers
Hi, On 2023-01-12 20:35:43 +1300, Thomas Munro wrote: > Subject: [PATCH] Fix WaitEventSetWait() buffer overrun. > > The WAIT_USE_EPOLL and WAIT_USE_KQUEUE implementations of > WaitEventSetWaitBlock() confused the size of their internal buffer with > the size of the caller's output buffer, and could ask the kernel for too > many events. In fact the set of events retrieved from the kernel needs > to be able to fit in both buffers, so take the minimum of the two. > > The WAIT_USE_POLL and WAIT_USE WIN32 implementations didn't have this > confusion. > This probably didn't come up before because we always used the same > number in both places, but commit 7389aad6 calculates a dynamic size at > construction time, while using MAXLISTEN for its output event buffer on > the stack. That seems like a reasonable thing to want to do, so > consider this to be a pre-existing bug worth fixing. > As reported by skink, valgrind and Tom Lane. > > Discussion: https://postgr.es/m/901504.1673504836%40sss.pgh.pa.us Makes sense. We should backpatch this, I think? Greetings, Andres Freund
Commits
-
Remove unneeded volatile qualifiers from postmaster.c.
- 8d2c1913ed3d 16.0 landed
-
Fix WaitEventSetWait() buffer overrun.
- f1821b58fc8d 16.0 landed
- 8a98523a542f 15.2 landed
- 547e60b8317e 14.7 landed
- c159b0383fa6 13.10 landed
- bf388ab82850 12.14 landed
- 1b40710a8c89 11.19 landed
-
Refactor DetermineSleepTime() to use milliseconds.
- 5a26c7b310b6 16.0 landed
-
Use WaitEventSet API for postmaster's event loop.
- 7389aad63666 16.0 landed
-
Allow parent's WaitEventSets to be freed after fork().
- b5d0f8ec01c0 16.0 landed
-
Don't leak a signalfd when using latches in the postmaster.
- 1f0019de2fe3 16.0 landed
-
Add WL_SOCKET_ACCEPT event to WaitEventSet API.
- 30829e52ff1a 16.0 landed
-
From: Phil Thompson <phil@river-bank.demon.co.uk>
- d5bbe2aca55b 7.1.1 cited