| From: | Tender Wang <tndrwang(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Unsafe access BufferDescriptors array in BufferGetLSNAtomic() |
| Date: | 2024-11-07 11:07:35 |
| Message-ID: | CAHewXNku-o46-9cmUgyv6LkSZ25doDrWq32p=oz9kfD8ovVJMg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Fix-unsafe-access-BufferDescriptors.patch | application/octet-stream | 1.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Kapila | 2024-11-07 11:10:51 | Re: Linkify mentions of the primary/subscriber's max_replication_slots |
| Previous Message | Alena Rybakina | 2024-11-07 11:06:37 | Re: Incremental Sort Cost Estimation Instability |