hwasan: enable mmap interception (no tagging used)
authorThurston Dang <thurston@google.com>
Thu, 25 May 2023 20:37:11 +0000 (20:37 +0000)
committerThurston Dang <thurston@google.com>
Fri, 26 May 2023 16:34:10 +0000 (16:34 +0000)
commit6ce34c089bf6806a40359b0ecaba7ffbfc809a7d
treebf49ccfc78cc3975beb48143b56542c0792f9337
parenta731c5f01d5a7cd6bc150c11498fe46fbd5bab94
hwasan: enable mmap interception (no tagging used)

This enables HWASan interception for mmap, to prevent users from allocating in the shadow memory regions. For compatibility, it does not use pointer tagging, nor does it allow MAP_FIXED with a tagged address.

This patch initializes the common interceptors, but that should be a no-op (except for the mmap interceptor), due to the disable-by-default nature of hwasan_platform_interceptors.h (from D150708). As the first patch to utilize this common interceptor machinery for HWASan, it also defines some macros (e.g., COMMON_INTERCEPT_FUNCTION) that will be useful as future interceptors are enabled.

TestCases/Posix/mmap_write_exec.cpp now passes for HWASan.

Reviewed By: kstoimenov, vitalybuka

Differential Revision: D151262
compiler-rt/lib/hwasan/hwasan_interceptors.cpp
compiler-rt/lib/hwasan/hwasan_platform_interceptors.h
compiler-rt/test/sanitizer_common/TestCases/Posix/mmap_write_exec.cpp