From 3c157ad116715aba84d3fb828a91aeaad002f92a Mon Sep 17 00:00:00 2001 From: David Rowley Date: Fri, 16 Oct 2026 17:59:08 +1300 Subject: [PATCH] Add sentinel_ok() check to BumpCheck(). Effectively an oversight in 29f6a959cf. The code went to the trouble of doing set_sentinel() but no code ever checked it was still set during BumpCheck(). Since bump context types are used in a handful of places, it very much makes sense to backpatch this to where bump.c was added so we can more easily discover any memory stomping bugs. Reported-by: shihao zhong Author: David Rowley Discussion: https://postgr.es/m/CAGRkXqQxTCthDEnw_10OEGLVNMUeyE4So-K29jmn9nAkxtr1ow@mail.gmail.com Backpatch-through: 17 --- src/backend/utils/mmgr/bump.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/backend/utils/mmgr/bump.c b/src/backend/utils/mmgr/bump.c index 9bb579935db..ca94ec03292 100644 --- a/src/backend/utils/mmgr/bump.c +++ b/src/backend/utils/mmgr/bump.c @@ -823,6 +823,10 @@ BumpCheck(MemoryContext context) if (chunkblock != block) elog(WARNING, "problem in Bump %s: bogus block link in block %p, chunk %p", name, block, chunk); + + if (!sentinel_ok(MemoryChunkGetPointer(chunk), chunk->requested_size)) + elog(WARNING, "problem in Bump %s: detected write past chunk end in block %p, chunk %p", + name, block, chunk); } if (has_external_chunk && nchunks > 1)