[PATCH] pg_surgery: check the page header and line pointers

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: [PATCH] pg_surgery: check the page header and line pointers
Date: 2026-09-05 03:48:01
Message-ID: CAGRkXqSC1ZBgk0crX0qHdV5bA8d1refEPS3fmJkk2kKo2qb0Lw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers.

heap_force_kill() and heap_force_freeze() index a stack array,
include_this_tid[MaxHeapTuplesPerPage], using PageGetMaxOffsetNumber().

That comes from pd_lower, so a page with pd_lower, pd_upper and
pd_special all 8192 passes PageIsVerified() but has max offset
(8192 - 24) / 4. The array is then read past its end and the backend
crashes.

ERROR: AddressSanitizer: stack-buffer-overflow READ at heap_surgery.c:256
[32, 323) 'include_this_tid' <== overflows

Superuser and owner only, so not a security issue.

Thanks,
Shihao

Attachment Content-Type Size
0001-pg_surgery-bound-the-page-s-max-offset-by-MaxHeapTup.patch application/octet-stream 3.4 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message shihao zhong 2026-09-05 03:56:44 Re: aio: Don't silently drop wait_event_info
Previous Message shihao zhong 2026-09-05 03:45:11 Re: logical decoding: skip unnecessary snapshot distribution.