]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: pools: ensure items are always large enough for the pool_cache_item
authorWilly Tarreau <w@1wt.eu>
Mon, 7 Feb 2022 09:32:00 +0000 (10:32 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 14 Feb 2022 19:10:43 +0000 (20:10 +0100)
commitb5ba09ed589c4e15f2b60c59f55da84e06689631
tree7ac72f59afdc6034badf1606636d6750abe3a48b
parent547aa0e95ec3445c788e09207a225e4dbff294c7
BUG/MEDIUM: pools: ensure items are always large enough for the pool_cache_item

With the introduction of DEBUG_POOL_TRACING in 2.6-dev with commit
add43fa43 ("DEBUG: pools: add new build option DEBUG_POOL_TRACING"), small
pools might be too short to store both the pool_cache_item struct and the
caller location, resulting in memory corruption and crashes when this debug
option is used.

What happens here is that the way the size is calculated is by considering
that the POOL_EXTRA part is only used while the object is in use, but this
is not true anymore for the caller's pointer which must absolutely be placed
after the pool_cache_item.

This patch makes sure that the caller part will always start after the
pool_cache_item and that the allocation will always be sufficent. This is
only tagged medium because the debug option is new and unlikely to be used
unless requested by a developer.

No backport is needed.
src/pool.c