pgsql: Fix unsafe access to BufferDescriptors - Mailing list pgsql-committers

From Richard Guo
Subject pgsql: Fix unsafe access to BufferDescriptors
Date
Msg-id E1tkZcA-0003mf-12@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix unsafe access to BufferDescriptors

When considering a local buffer, the GetBufferDescriptor() call in
BufferGetLSNAtomic() would be retrieving a shared buffer with a bad
buffer ID.  Since the code checks whether the buffer is shared before
using the retrieved BufferDesc, this issue did not lead to any
malfunction.  Nonetheless this seems like trouble waiting to happen,
so fix it by ensuring that GetBufferDescriptor() is only called when
we know the buffer is shared.

Author: Tender Wang <tndrwang@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CAHewXNku-o46-9cmUgyv6LkSZ25doDrWq32p=oz9kfD8ovVJMg@mail.gmail.com
Backpatch-through: 13

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/07a55093cd2e80be5fb54c867208ef6c52bd00ce

Modified Files
--------------
src/backend/storage/buffer/bufmgr.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Update to latest Snowball sources.
Next
From: Richard Guo
Date:
Subject: pgsql: Fix unsafe access to BufferDescriptors