Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xC7JR-00000003afi-48eq for pgsql-hackers@arkaria.postgresql.org; Thu, 01 Oct 2026 03:18:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xC7JQ-000000052o5-0tSo for pgsql-hackers@arkaria.postgresql.org; Thu, 01 Oct 2026 03:18:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xC7JP-000000052nx-3wl9 for pgsql-hackers@lists.postgresql.org; Thu, 01 Oct 2026 03:18:23 +0000 Received: from email.dnscdc.tech ([194.226.250.15]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xC7JN-00000002CnV-0FRJ for pgsql-hackers@lists.postgresql.org; Thu, 01 Oct 2026 03:18:23 +0000 Received: with id AB805280925; Thu, 1 Oct 2026 10:18:18 +0700 (+07) Received: with id 6B261280056; Thu, 1 Oct 2026 10:18:18 +0700 (+07) From: Grigorev Jurij To: Michael Paquier CC: Rahul Yadav , "pgsql-hackers@lists.postgresql.org" Subject: Re: BUG #19599: RestoreBlockImage: the decode cross-checks never bound hole_offset + hole_length against BLCKSZ Thread-Topic: BUG #19599: RestoreBlockImage: the decode cross-checks never bound hole_offset + hole_length against BLCKSZ Thread-Index: AQHdPEAamNcHbRVPaUWRhlpYNzs5kLbgwaWAgASXPOSAAicbAIAAmqKk Date: Thu, 1 Oct 2026 03:18:11 +0000 Message-ID: References: , In-Reply-To: Accept-Language: ru-RU, en-US Content-Language: ru-RU X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-KLMS-Rule-ID: 1 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Lua-Profiles: 206349 [Sep 30 2026] X-KLMS-AntiSpam-Version: 6.1.1.27 X-KLMS-AntiSpam-Envelope-From: ju.grigorev@ftdata.ru X-KLMS-AntiSpam-Rate: 0 X-KLMS-AntiSpam-Status: not_detected X-KLMS-AntiSpam-Method: none X-KLMS-AntiSpam-Auth: dkim=none X-MS-Exchange-Organization-SCL: -1 X-KLMS-AntiSpam-Interceptor-Info: scan successful X-KLMS-AntiPhishing: Clean, bases: 2026/10/01 02:39:00 X-KLMS-AntiVirus: Kaspersky Security for Linux Mail Server, version 8.0.3.30, bases: 2026/10/01 01:29:00 #28643280 X-KLMS-AntiVirus-Status: Clean, skipped List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 =3D=3D 0, hole_length =3D=3D 0, bimg_len =3D=3D 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=