The bump allocator hands out chunks from one big malloc, so AddressSanitizer
cannot see a write that underflows one chunk into its neighbour -- e.g. a
miscomputed F_SUM() that reaches before a file_struct's extras (the
FLAG_HLINKED-without-H bug). Under ASan, poison a small redzone just below
each returned chunk (allocations grow downward from the top of an extent) so
such an underflow becomes a hard use-after-poison report; unpoison a whole
extent whenever its space is reused (reset/reclaim) so legitimate later
allocations never trip over an old redzone. Compiled out entirely without
-fsanitize=address.
Validated: a deliberate write 12 bytes below F_SUM is caught as a
use-after-poison; the existing suite (hardlinks/inc-recurse, daemon, xattrs,
merge) is clean under ASan, so the redzone introduces no false positives.
Also add a require_asan() test helper (mirrors require_tcp) for tests that are
only meaningful under an ASan build.
(cherry picked from commit 402962b7cdea8afb27c0e6e198fef62172c751e3)
Clang rightfully complains about invoking bomb(..) without a proper prototype:
lib/pool_alloc.c:171:16: warning: passing arguments to a function without a prototype
is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
(*pool->bomb)(bomb_msg, __FILE__, __LINE__);
^
1 warning generated.
Signed-off-by: Holger Hoffstätte <holger@applied-asynchrony.com>
(making pools aligned by default). Added the missing code to make the
documented behavior of pool_free() with a NULL addr work. Updated the
pool_alloc.3 manpage.
item was trying to make that memory available to the pool, but it
failed to adjust the right variable.
- Fixed a bug in pool_free() where the return of the entire live
extent back to unallocated status did not obey POOL_CLEAR.
- Use the new() and new_array() functions instead of malloc().
- Changed the sqew variable to skew.
- Some other minor formatting tweaks.