1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

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 <zhong950419@gmail.com>
Author: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/CAGRkXqQxTCthDEnw_10OEGLVNMUeyE4So-K29jmn9nAkxtr1ow@mail.gmail.com
Backpatch-through: 17
This commit is contained in:
David Rowley
2026-10-16 18:00:44 +13:00
parent 96823bfd7c
commit 86848d19bd

View File

@@ -794,6 +794,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)