]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix MarkBufferDirtyHint() to not call GetBufferDescriptor() for local buffers
authorMichael Paquier <michael@paquier.xyz>
Wed, 10 Jun 2026 04:49:26 +0000 (13:49 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 10 Jun 2026 04:49:26 +0000 (13:49 +0900)
commite18b0cb7344cb4bd28468f6c0aeeb9b9241d30aa
treea01f884f9b0bd385e21944d957b06d65bc8c4c6c
parentb70d5672d0c5d4310965fcbc1c846c9d111a3046
Fix MarkBufferDirtyHint() to not call GetBufferDescriptor() for local buffers

GetBufferDescriptor() was called before checking if the buffer is local.
Such buffers have a negative ID, meaning that we could call
GetBufferDescriptor() with a wrapped-around uint32 value causing a
potential out-of-bound access to the BufferDescriptors array.

This is harmless in the existing code for the current uses of
MarkBufferDirtyHint(), but the author has found a way to make that
buggy while working on a different patch set, and the order of the
operations is wrong.

Oversight in 82467f627bd4.  No backpatch is required, as this is new to
v19.

Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://postgr.es/m/CAExHW5uzRMYVZsXXS3HXXT0fG_sNrpUhUqwP4NorhaCqH9JDhA@mail.gmail.com
src/backend/storage/buffer/bufmgr.c