diff --git a/compiler-rt/lib/hwasan/hwasan_allocator.h b/compiler-rt/lib/hwasan/hwasan_allocator.h --- a/compiler-rt/lib/hwasan/hwasan_allocator.h +++ b/compiler-rt/lib/hwasan/hwasan_allocator.h @@ -29,6 +29,8 @@ #if HWASAN_WITH_INTERCEPTORS DECLARE_REAL(void *, realloc, void *ptr, uptr size) DECLARE_REAL(void, free, void *ptr) +DECLARE_REAL(void *, malloc, SIZE_T size); +DECLARE_REAL(void *, calloc, SIZE_T nmemb, SIZE_T size); #endif namespace __hwasan { diff --git a/compiler-rt/lib/hwasan/hwasan_allocator.cpp b/compiler-rt/lib/hwasan/hwasan_allocator.cpp --- a/compiler-rt/lib/hwasan/hwasan_allocator.cpp +++ b/compiler-rt/lib/hwasan/hwasan_allocator.cpp @@ -25,6 +25,8 @@ #if HWASAN_WITH_INTERCEPTORS DEFINE_REAL(void *, realloc, void *ptr, uptr size) DEFINE_REAL(void, free, void *ptr) +DEFINE_REAL(void *, malloc, SIZE_T size); +DEFINE_REAL(void *, calloc, SIZE_T nmemb, SIZE_T size); #endif namespace __hwasan { @@ -120,6 +122,13 @@ Thread *t = GetCurrentThread(); void *allocated; if (t) { +#if HWASAN_WITH_INTERCEPTORS + if (t->TaggingIsDisabled() && !flags()->disable_allocator_tagging) + if (zeroise) + return REAL(calloc)(1, orig_size); + else + return REAL(malloc)(orig_size); +#endif allocated = allocator.Allocate(t->allocator_cache(), size, alignment); } else { SpinMutexLock l(&fallback_mutex); diff --git a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp --- a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp +++ b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp @@ -359,6 +359,8 @@ #endif // __aarch64__ INTERCEPT_FUNCTION(realloc); INTERCEPT_FUNCTION(free); + INTERCEPT_FUNCTION(malloc); + INTERCEPT_FUNCTION(calloc); #endif inited = 1;