MEDIUM: pools: detect() when munmap() fails in UAF mode

Better check that munmap() always works, otherwise it means we might
have miscalculated an address, and if it fails silently, it will eat
all the memory extremely quickly. Let's add a BUG_ON() on munmap's
return.
This commit is contained in:
Willy Tarreau 2025-10-13 19:22:31 +02:00
parent 0e6a233217
commit 17930edecc

View File

@ -97,7 +97,8 @@ static inline void pool_free_area_uaf(void *area, size_t size)
if (pad >= sizeof(void *) && *(void **)(area - sizeof(void *)) != area)
ABORT_NOW();
munmap(area - pad, (size + 4095) & -4096);
/* better know immediately if an address calculation was wrong! */
BUG_ON(munmap(area - pad, (size + 4095) & -4096) == -1);
}
#endif /* _HAPROXY_POOL_OS_H */