From bcf1b3584704e3fea441067afb5cc1c5c875f770 Mon Sep 17 00:00:00 2001 From: Andrey Kazmin Date: Tue, 8 Jun 2021 16:25:32 +0300 Subject: [PATCH] Added no_sanitize_hwaddress attribute for address_in_range Added new attribute for address_in_range to disable HWASan instrumentation. Change-Id: I4c446585f144f034dc79e4dc938ef4b8f8401199 Signed-off-by: Andrey Kazmin --- Objects/obmalloc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index eb34f10b..9284c7ff 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -34,6 +34,10 @@ static void _PyMem_SetupDebugHooksDomain(PyMemAllocatorDomain domain); # define _Py_NO_SANITIZE_ADDRESS \ __attribute__((no_sanitize("address"))) # endif +# if __has_feature(hwaddress_sanitizer) /* is ASAN enabled? */ +# define _Py_NO_SANITIZE_HWADDRESS \ + __attribute__((no_sanitize("hwaddress"))) +# endif # if __has_feature(thread_sanitizer) /* is TSAN enabled? */ # define _Py_NO_SANITIZE_THREAD __attribute__((no_sanitize_thread)) # endif @@ -44,6 +48,10 @@ static void _PyMem_SetupDebugHooksDomain(PyMemAllocatorDomain domain); # if defined(__SANITIZE_ADDRESS__) /* GCC 4.8+, is ASAN enabled? */ # define _Py_NO_SANITIZE_ADDRESS \ __attribute__((no_sanitize_address)) +# endif +# if defined(__SANITIZE_HWADDRESS__) /* GCC 10+, is HWASAN enabled? */ +# define _Py_NO_SANITIZE_HWADDRESS \ + __attribute__((no_sanitize_hwaddress)) # endif // TSAN is supported since GCC 5.1, but __SANITIZE_THREAD__ macro // is provided only since GCC 7. @@ -55,6 +63,9 @@ static void _PyMem_SetupDebugHooksDomain(PyMemAllocatorDomain domain); #ifndef _Py_NO_SANITIZE_ADDRESS # define _Py_NO_SANITIZE_ADDRESS #endif +#ifndef _Py_NO_SANITIZE_HWADDRESS +# define _Py_NO_SANITIZE_HWADDRESS +#endif #ifndef _Py_NO_SANITIZE_THREAD # define _Py_NO_SANITIZE_THREAD #endif @@ -1408,6 +1419,7 @@ extremely desirable that it be this fast. */ static bool _Py_NO_SANITIZE_ADDRESS + _Py_NO_SANITIZE_HWADDRESS _Py_NO_SANITIZE_THREAD _Py_NO_SANITIZE_MEMORY address_in_range(void *p, poolp pool) -- 2.34.1