pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix reusing large allocations in generation memory contexts
Date: Mon, 09 Nov 2026 14:21:52 +0000
Message-ID: <E1xQQFs-000000003Ql-44qv@gemulon.postgresql.org> (raw)

Fix reusing large allocations in generation memory contexts

If an allocation larger than 1 GB is made from a generation memory
context, and the allocation is later freed, don't try to reuse the
block for smaller allocations later.  The problem is that the standard
layout for a MemoryChunk cannot represent cannot represent an offset
larger than 1 GB (MEMORYCHUNK_MAX_BLOCKOFFSET) from the beginning of
the block, so if MemoryChunk is carved from the very end of the larger
block, the offset stored in the memory chunk overflows.  That leads to
memory corruption.

Backpatch to version 15, where the reuse of blocks was introduced,
although the segfault is only reproducable on version 16 onwards.
Version 15 used a custom GenerationChunk struct which didn't have the
overflow risk that the MemoryChunk struct used in later versions has.

Reported-by: Jayden Sarveshkumar <jayden@verialabs.com>
Reviewed-by: Noah Misch <noah@leadboat.com>
Backpatch-through: v15
Security: CVE-2026-116328

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/dfb3505b909b2988b11d503a6b07f1e78017f668
Author: Heikki Linnakangas <heikki.linnakangas@iki.fi>

Modified Files
--------------
src/backend/utils/mmgr/generation.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)



view thread (4+ messages)  latest in thread

Message-ID: <E1xQQFs-000000003Ql-44qv@gemulon.postgresql.org>
Permalink:  ../E1xQQFs-000000003Ql-44qv@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xQQFs-000000003Ql-44qv@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: noah@leadboat.com
  Subject: Re: pgsql: Fix reusing large allocations in generation memory contexts
  In-Reply-To: <E1xQQFs-000000003Ql-44qv@gemulon.postgresql.org>
  References: <E1xQQFs-000000003Ql-44qv@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox