Re: Bug: XLogReader mishandles oversized multi-page xl_tot_len (potential memory corruption)

From: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: David K <dkarapetyan(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Bug: XLogReader mishandles oversized multi-page xl_tot_len (potential memory corruption)
Date: 2026-08-03 09:23:47
Message-ID: CAEze2Whm0Ha9hbVm3MiV2ZKugjjJsT-xgK4ZKWTPqwDWBWNc=A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 3 Aug 2026 at 01:21, Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Sun, Aug 02, 2026 at 04:08:17PM +0900, Michael Paquier wrote:
> > - newSize += XLOG_BLCKSZ - (newSize % XLOG_BLCKSZ);
> > + Assert(reclength <= INT32_MAX - BLCKSZ);
> > +
> > + newSize = TYPEALIGN(XLOG_BLCKSZ, reclength);
> >
> > Am I reading a typo here or the INT32_MAX is missing a 'PG_U'?
> > XLogRecordMaxSize cannot reach that, just wondering about a
> > consistency argument with the surrounding type declarations for these
> > length variables.

Yes, that was an oversight in my submission.
It's been changed to XLogRecordMaxSize, with a new comment, in the
attached patch.

> Another thing to note: this basically breaks the recovery test
> 039_end_of_wal.pl. Could you look at that please?

Also fixed, including a new test case for >XLogRecordMaxSize.

-Matthias

Attachment Content-Type Size
v4-0001-Fix-XLogReader-mishandling-of-oversized-multi-pag.patch application/octet-stream 8.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message chee.wooson 2026-08-03 09:31:41 [PATCH v3] Fix exported snapshot xmin handoff race
Previous Message Andrey Borodin 2026-08-03 09:16:33 Re: walsummarizer can get stuck when switching timelines