Add __sanitizer_get_allocated_begin API and implementations
authorThurston Dang <thurston@google.com>
Mon, 3 Apr 2023 21:14:40 +0000 (21:14 +0000)
committerThurston Dang <thurston@google.com>
Mon, 3 Apr 2023 21:27:51 +0000 (21:27 +0000)
commit415b1cfd57de62da8af9ad8dc567fc9d918dbaa5
tree2135abc352ac9411a10dbc0c9e1764ad89c49df3
parentde92a2013196d9119a5cf33e9a18d4b8a8d1e3df
Add __sanitizer_get_allocated_begin API and implementations

This function will return the start of the allocation, if given a pointer that lies within an allocation. Otherwise, it returns NULL.

It will be useful for detecting dynamic TLS allocations in glibc >=2.25, which
uses malloc (see https://github.com/google/sanitizers/issues/1409#issuecomment-1214244142).

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D147005
12 files changed:
compiler-rt/include/sanitizer/allocator_interface.h
compiler-rt/lib/asan/asan_allocator.cpp
compiler-rt/lib/dfsan/dfsan_allocator.cpp
compiler-rt/lib/hwasan/hwasan_allocator.cpp
compiler-rt/lib/lsan/lsan_allocator.cpp
compiler-rt/lib/memprof/memprof_allocator.cpp
compiler-rt/lib/msan/msan_allocator.cpp
compiler-rt/lib/sanitizer_common/sanitizer_allocator_interface.h
compiler-rt/lib/sanitizer_common/sanitizer_allocator_internal.h
compiler-rt/lib/sanitizer_common/sanitizer_common_interface.inc
compiler-rt/lib/tsan/rtl/tsan_mman.cpp
compiler-rt/test/sanitizer_common/TestCases/get_allocated_begin.cpp [new file with mode: 0644]