[COMMITTERS] pgsql: Fix locking in WAL receiver/sender shmem state structs

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема [COMMITTERS] pgsql: Fix locking in WAL receiver/sender shmem state structs
Дата
Msg-id E1dR45p-0001CU-JL@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix locking in WAL receiver/sender shmem state structs

In WAL receiver and WAL server, some accesses to their corresponding
shared memory control structs were done without holding any kind of
lock, which could lead to inconsistent and possibly insecure results.

In walsender, fix by clarifying the locking rules and following them
correctly, as documented in the new comment in walsender_private.h;
namely that some members can be read in walsender itself without a lock,
because the only writes occur in the same process.  The rest of the
struct requires spinlock for accesses, as usual.

In walreceiver, fix by always holding spinlock while accessing the
struct.

While there is potentially a problem in all branches, it is minor in
stable ones.  This only became a real problem in pg10 because of quorum
commit in synchronous replication (commit 3901fd70cc7c), and a potential
security problem in walreceiver because a superuser() check was removed
by default monitoring roles (commit 25fff40798fc).  Thus, no backpatch.

In passing, clean up some leftover braces which were used to create
unconditional blocks.  Once upon a time these were used for
volatile-izing accesses to those shmem structs, which is no longer
required.  Many other occurrences of this pattern remain.

Author: Michaël Paquier
Reported-by: Michaël Paquier
Reviewed-by: Masahiko Sawada, Kyotaro Horiguchi, Thomas Munro,
    Robert Haas
Discussion: https://postgr.es/m/CAB7nPqTWYqtzD=LN_oDaf9r-hAjUEPAy0B9yRkhcsLdRN8fzrw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/572d6ee6d41b43b8871f42c7dbbef795523b2dbf

Modified Files
--------------
src/backend/replication/syncrep.c           | 32 ++++++++++++++++----
src/backend/replication/walreceiver.c       | 42 +++++++++++++-------------
src/backend/replication/walsender.c         | 46 +++++++++++++----------------
src/include/replication/walreceiver.h       |  6 ++--
src/include/replication/walsender_private.h |  9 +++++-
5 files changed, 80 insertions(+), 55 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: [COMMITTERS] pgsql: PL/Python: Fix hint about returning composite type from Python
Следующее
От: Peter Eisentraut
Дата:
Сообщение: [COMMITTERS] pgsql: Fix UPDATE of GENERATED ALWAYS identity columns