Skip to content

Commit

Permalink
Move details into hwasan
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalybuka committed Nov 7, 2023
1 parent a2b64d3 commit 8129287
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 11 additions & 3 deletions compiler-rt/lib/hwasan/hwasan_interceptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,17 @@ struct HWAsanInterceptorContext {
(void)(name); \
} while (false)

# define COMMON_INTERCEPTOR_MEMSET_IMPL(ctx, dst, v, size) \
{ \
if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED) \
return internal_memset(dst, v, size); \
COMMON_INTERCEPTOR_ENTER(ctx, memset, dst, v, size); \
if (MemIsApp(UntagAddr(reinterpret_cast<uptr>(dst))) && \
common_flags()->intercept_intrin) \
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, size); \
return REAL(memset)(dst, v, size); \
}

# define COMMON_INTERCEPTOR_STRERROR() \
do { \
} while (false)
Expand All @@ -155,9 +166,6 @@ struct HWAsanInterceptorContext {

# define COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED (!hwasan_inited)

# define COMMON_INTERCEPTOR_MEMSET_CHECK_IN_APP_MEM(p) \
MemIsApp(UntagAddr(reinterpret_cast<uptr>(p)))

// The main purpose of the mmap interceptor is to prevent the user from
// allocating on top of shadow pages.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,11 @@
#define PLATFORM_HAS_DIFFERENT_MEMCPY_AND_MEMMOVE 1
#endif // SANITIZER_APPLE

#ifndef COMMON_INTERCEPTOR_MEMSET_CHECK_IN_APP_MEM
#define COMMON_INTERCEPTOR_MEMSET_CHECK_IN_APP_MEM(p) (0)
#endif

#ifndef COMMON_INTERCEPTOR_MEMSET_IMPL
#define COMMON_INTERCEPTOR_MEMSET_IMPL(ctx, dst, v, size) \
{ \
if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED) \
return internal_memset(dst, v, size); \
if (!COMMON_INTERCEPTOR_MEMSET_CHECK_IN_APP_MEM(dst)) \
return internal_memset(dst, v, size); \
COMMON_INTERCEPTOR_ENTER(ctx, memset, dst, v, size); \
if (common_flags()->intercept_intrin) \
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, size); \
Expand Down

0 comments on commit 8129287

Please sign in to comment.