Re: BUG #19599: RestoreBlockImage: the decode cross-checks never bound hole_offset + hole_length against BLCKSZ

From: Grigorev Jurij <ju(dot)grigorev(at)ftdata(dot)ru>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Rahul Yadav <rahul(at)rhyadav(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #19599: RestoreBlockImage: the decode cross-checks never bound hole_offset + hole_length against BLCKSZ
Date: 2026-10-01 03:18:11
Message-ID: f416177295864b52a2351cb44b9418a0@localhost.localdomain
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Hi Michael,

Thanks for looking! I agree XLogRecordAssemble() never writes
such a hole, CRC catches accidental corruption, and core WAL is
trusted.

My only point was that DecodeXLogRecord() already distrusts these
fields enough to cross-check them: it rejects hole_offset == 0,
hole_length == 0, bimg_len == BLCKSZ when HAS_HOLE is set, and
non-zero hole fields when it is not set. Bounding
hole_offset + hole_length against BLCKSZ just completes that
existing family of checks. Rahul's repro shows a re-CRCed record
still passes decode and then crashes pg_waldump --save-fullpage.

I agree the test in 0002 is quite large for such a small check --
happy to drop it entirely. To keep this minimal, we could keep
just the two-line check in DecodeXLogRecord() with no extra test --
the existing HAS_HOLE error message, no new paths.

I don't insist on the test or backpatch -- if you prefer, let's
keep only the decode check, or close it if you think even that
is not wanted. Should xlogreader be robust here, or may
RestoreBlockImage() assume trusted input after CRC?

I understand from your message that you lean towards this not
being needed, given trusted WAL, CRC and the insertion bounds --
just wanted to understand where the line is. Happy to update
or close as you suggest.

Kind regards,
Yuriy

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Masahiko Sawada 2026-10-01 03:35:36 Re: autovacuum: automatically propagate updated parameters
Previous Message Ajin Cherian 2026-10-01 03:09:19 Re: BUG #19728: A logical replication apply worker segfaults dereferencing a NULL `MyLogicalRepWorker->stream_filese

Browse pgsql-hackers by date

  From Date Subject
Next Message shihao zhong 2026-10-01 03:18:23 Re: Report index currently being vacuumed in pg_stat_progress_vacuum
Previous Message Sami Imseih 2026-10-01 03:16:23 Re: Report index currently being vacuumed in pg_stat_progress_vacuum