DEBUG: pools: add new build option DEBUG_POOL_INTEGRITY
authorWilly Tarreau <w@1wt.eu>
Fri, 21 Jan 2022 18:00:25 +0000 (19:00 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 26 Jan 2022 07:29:15 +0000 (08:29 +0100)
commit722601212a6403fede5f55d65a3d082721bf1678
tree65d747bbbf25cc8c73bb0602132fb68c75e7a546
parent0dcd46eadc2033ff858523be2d25b1cfce4a1209
DEBUG: pools: add new build option DEBUG_POOL_INTEGRITY

When enabled, objects picked from the cache are checked for corruption
by comparing their contents against a pattern that was placed when they
were inserted into the cache. Objects are also allocated in the reverse
order, from the oldest one to the most recent, so as to maximize the
ability to detect such a corruption. The goal is to detect writes after
free (or possibly hardware memory corruptions). Contrary to DEBUG_UAF
this cannot detect reads after free, but may possibly detect later
corruptions and will not consume extra memory. The CPU usage will
increase a bit due to the cost of filling/checking the area and for the
preference for cold cache instead of hot cache, though not as much as
with DEBUG_UAF. This option is meant to be usable in production.

(cherry picked from commit 0575d8fd760c6cd1de3d6ed66599d685a03c1873)
[wt: adjusted slightly since there is no batch refilling in 2.5; dropped
 the API doc parts; tested with/without option and works fine]
Signed-off-by: Willy Tarreau <w@1wt.eu>
Makefile
include/haproxy/pool-t.h
include/haproxy/pool.h
src/pool.c