diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2019-01-18 19:46:00 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2019-01-18 19:46:00 +0000 |
commit | 05342ccc9cff16425c0a831fddd510879544a0bf (patch) | |
tree | d86b2dfee6aa9d3a54d6d21aabb6bd7462b6669b /lib/hwasan/hwasan_interceptors.cc | |
parent | 6fc0ad0a5de45f80140620e2dd606f65d547362a (diff) | |
parent | b15181368831966c0ec1824617a4c95853fd1b92 (diff) | |
download | compiler-rt-05342ccc9cff16425c0a831fddd510879544a0bf.tar.gz |
Creating branches/google/stable and tags/google/stable/2019-01-18 from r351319
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/branches/google/stable@351578 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/hwasan/hwasan_interceptors.cc')
-rw-r--r-- | lib/hwasan/hwasan_interceptors.cc | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/lib/hwasan/hwasan_interceptors.cc b/lib/hwasan/hwasan_interceptors.cc index d20bdd95a..fb0dcb890 100644 --- a/lib/hwasan/hwasan_interceptors.cc +++ b/lib/hwasan/hwasan_interceptors.cc @@ -17,6 +17,7 @@ #include "interception/interception.h" #include "hwasan.h" +#include "hwasan_allocator.h" #include "hwasan_mapping.h" #include "hwasan_thread.h" #include "hwasan_poisoning.h" @@ -44,11 +45,6 @@ using __sanitizer::atomic_load; using __sanitizer::atomic_store; using __sanitizer::atomic_uintptr_t; -DECLARE_REAL(SIZE_T, strlen, const char *s) -DECLARE_REAL(SIZE_T, strnlen, const char *s, SIZE_T maxlen) -DECLARE_REAL(void *, memcpy, void *dest, const void *src, uptr n) -DECLARE_REAL(void *, memset, void *dest, int c, uptr n) - bool IsInInterceptorScope() { Thread *t = GetCurrentThread(); return t && t->InInterceptorScope(); @@ -130,13 +126,13 @@ void * __sanitizer_pvalloc(uptr size) { void __sanitizer_free(void *ptr) { GET_MALLOC_STACK_TRACE; if (!ptr || UNLIKELY(IsInDlsymAllocPool(ptr))) return; - HwasanDeallocate(&stack, ptr); + hwasan_free(ptr, &stack); } void __sanitizer_cfree(void *ptr) { GET_MALLOC_STACK_TRACE; if (!ptr || UNLIKELY(IsInDlsymAllocPool(ptr))) return; - HwasanDeallocate(&stack, ptr); + hwasan_free(ptr, &stack); } uptr __sanitizer_malloc_usable_size(const void *ptr) { @@ -222,33 +218,15 @@ INTERCEPTOR_ALIAS(void, malloc_stats, void); #endif // HWASAN_WITH_INTERCEPTORS -#if HWASAN_WITH_INTERCEPTORS -extern "C" int pthread_attr_init(void *attr); -extern "C" int pthread_attr_destroy(void *attr); - -struct ThreadStartArg { - thread_callback_t callback; - void *param; -}; - -static void *HwasanThreadStartFunc(void *arg) { - __hwasan_thread_enter(); - ThreadStartArg A = *reinterpret_cast<ThreadStartArg*>(arg); - UnmapOrDie(arg, GetPageSizeCached()); - return A.callback(A.param); -} - -INTERCEPTOR(int, pthread_create, void *th, void *attr, void *(*callback)(void*), - void * param) { +#if HWASAN_WITH_INTERCEPTORS && !defined(__aarch64__) +INTERCEPTOR(int, pthread_create, void *th, void *attr, + void *(*callback)(void *), void *param) { ScopedTaggingDisabler disabler; - ThreadStartArg *A = reinterpret_cast<ThreadStartArg *> (MmapOrDie( - GetPageSizeCached(), "pthread_create")); - *A = {callback, param}; int res = REAL(pthread_create)(UntagPtr(th), UntagPtr(attr), - &HwasanThreadStartFunc, A); + callback, param); return res; } -#endif // HWASAN_WITH_INTERCEPTORS +#endif static void BeforeFork() { StackDepotLockAll(); @@ -289,8 +267,12 @@ void InitializeInterceptors() { INTERCEPT_FUNCTION(fork); #if HWASAN_WITH_INTERCEPTORS +#if !defined(__aarch64__) INTERCEPT_FUNCTION(pthread_create); #endif + INTERCEPT_FUNCTION(realloc); + INTERCEPT_FUNCTION(free); +#endif inited = 1; } |