]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix unsafe access to BufferDescriptors
authorRichard Guo <rguo@postgresql.org>
Wed, 19 Feb 2025 02:05:35 +0000 (11:05 +0900)
committerRichard Guo <rguo@postgresql.org>
Wed, 19 Feb 2025 02:16:10 +0000 (11:16 +0900)
commita38a7ad51ec8dc558d71806d7f1aee986723ccbc
tree16ea0fe297f270c22073947e8c796f1481a68ddc
parente9c95c6d3616f4c106df763067fc40b0ca6efbd4
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
src/backend/storage/buffer/bufmgr.c