Unsafe access BufferDescriptors array in BufferGetLSNAtomic()
Tender Wang <tndrwang@gmail.com>
From: Tender Wang <tndrwang@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-11-07T11:07:35Z
Lists: pgsql-hackers
Attachments
- 0001-Fix-unsafe-access-BufferDescriptors.patch (application/octet-stream) patch 0001
Hi, While learning gist index insert codes, I find a little issue with BufferGetLSNAtomic(). At first, it wants to get bufHdr by accessing the buffer descriptor array, as below: BufferDesc *bufHdr = GetBufferDescriptor(buffer - 1); However, it doesn't check whether the passed buffer is a local or shared buffer. If the buffer is local, then buffer < 0; it will be cast to uint32 when passed to GetBufferDescriptor(). This may be unsafe, although no someone reports the problem. I tweak a few codes; see the attached patch. Any thoughts? -- Thanks, Tender Wang
Commits
-
Fix unsafe access to BufferDescriptors
- a38a7ad51ec8 13.21 landed
- 07a55093cd2e 14.18 landed
- 24a74986a096 15.13 landed
- 4c6b5dd5f5cf 16.9 landed
- 49a450892a3e 17.5 landed
- 71d02dc478d5 18.0 landed