| From: | Noah Misch <noah(at)leadboat(dot)com> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix reusing large allocations in generation memory contexts |
| Date: | 2026-11-09 14:22:02 |
| Message-ID: | E1xQQG2-000000003lW-2cze@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(at)verialabs(dot)com>
Reviewed-by: Noah Misch <noah(at)leadboat(dot)com>
Backpatch-through: v15
Security: CVE-2026-116328
Branch
------
REL_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/f34ccffddbe59d313d214d2a584147e735e00219
Author: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
Modified Files
--------------
src/backend/utils/mmgr/generation.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Noah Misch | 2026-11-09 14:22:03 | pgsql: Reject extnamespace if it's temporary or it's '$user'::regnamesp |
| Previous Message | Noah Misch | 2026-11-09 14:22:01 | pgsql: Introduce attribute versioning to prevent unsafe deforming |