Fix unsafe access to BufferDescriptors
authorRichard Guo <[email protected]>
Wed, 19 Feb 2025 02:05:35 +0000 (11:05 +0900)
committerRichard Guo <[email protected]>
Wed, 19 Feb 2025 02:14:13 +0000 (11:14 +0900)
commit07a55093cd2e80be5fb54c867208ef6c52bd00ce
tree29c9d78fd8703dd2fe161781b79875ac3450c72b
parent691c32ba4b194abf590ecf58baea46349f59f109
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 <[email protected]>
Reviewed-by: Xuneng Zhou <[email protected]>
Reviewed-by: Richard Guo <[email protected]>
Discussion: https://postgr.es/m/CAHewXNku-o46-9cmUgyv6LkSZ25doDrWq32p=oz9kfD8ovVJMg@mail.gmail.com
Backpatch-through: 13
src/backend/storage/buffer/bufmgr.c