pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix reusing large allocations in generation memory contexts 4+ messages / 1 participants [nested] [flat]
* pgsql: Fix reusing large allocations in generation memory contexts @ 2026-11-09 14:21 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 4+ messages in thread From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 ------ master Details ------- https://git.postgresql.org/pg/commitdiff/e27929e3b6d4175e9c1940aa016f8e3986f45cf6 Author: Heikki Linnakangas <heikki.linnakangas@iki.fi> Modified Files -------------- src/backend/utils/mmgr/generation.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix reusing large allocations in generation memory contexts @ 2026-11-09 14:21 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 4+ messages in thread From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix reusing large allocations in generation memory contexts @ 2026-11-09 14:21 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 4+ messages in thread From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/53a34a4defaa42c9d7013fbff491b78f41b5f18b Author: Heikki Linnakangas <heikki.linnakangas@iki.fi> Modified Files -------------- src/backend/utils/mmgr/generation.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix reusing large allocations in generation memory contexts @ 2026-11-09 14:22 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 4+ messages in thread From: Noah Misch @ 2026-11-09 14:22 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/f34ccffddbe59d313d214d2a584147e735e00219 Author: Heikki Linnakangas <heikki.linnakangas@iki.fi> Modified Files -------------- src/backend/utils/mmgr/generation.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2026-11-09 14:22 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-09 14:21 pgsql: Fix reusing large allocations in generation memory contexts Noah Misch <noah@leadboat.com> 2026-11-09 14:21 pgsql: Fix reusing large allocations in generation memory contexts Noah Misch <noah@leadboat.com> 2026-11-09 14:21 pgsql: Fix reusing large allocations in generation memory contexts Noah Misch <noah@leadboat.com> 2026-11-09 14:22 pgsql: Fix reusing large allocations in generation memory contexts Noah Misch <noah@leadboat.com>
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