[compiler-rt] d55982a - hwasan: lay groundwork for importing subset of sanitizer_common interceptors [NFC]
Thurston Dang via llvm-commits
llvm-commits at lists.llvm.org
Tue May 23 11:20:58 PDT 2023
Author: Thurston Dang
Date: 2023-05-23T18:16:46Z
New Revision: d55982ac8cced9e5d4816494658d90c84d0b4301
URL: https://github.com/llvm/llvm-project/commit/d55982ac8cced9e5d4816494658d90c84d0b4301
DIFF: https://github.com/llvm/llvm-project/commit/d55982ac8cced9e5d4816494658d90c84d0b4301.diff
LOG: hwasan: lay groundwork for importing subset of sanitizer_common interceptors [NFC]
This patch does the bare minimum to import sanitizer_common_interceptors, but
without actually enabling any interceptors or meaningfully defining the
COMMON_INTERCEPT macros.
This will allow selectively enabling sanitizer_common interceptors (if the
appropriate macros are defined), as suggested by Vitaly in D149701.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D150708
Added:
Modified:
compiler-rt/lib/hwasan/hwasan_interceptors.cpp
compiler-rt/lib/hwasan/hwasan_platform_interceptors.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
index 443bfe8108dc..60f262f0b3ae 100644
--- a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
@@ -16,6 +16,7 @@
#include "hwasan.h"
#include "hwasan_checks.h"
+#include "hwasan_platform_interceptors.h"
#include "hwasan_thread.h"
#include "hwasan_thread_list.h"
#include "interception/interception.h"
@@ -44,6 +45,101 @@ using namespace __hwasan;
# include "sanitizer_common/sanitizer_common_syscalls.inc"
# include "sanitizer_common/sanitizer_syscalls_netbsd.inc"
+#define COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ptr, size) \
+ do { \
+ } while (false)
+
+#define COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, size) \
+ do { \
+ (void)(ctx); \
+ (void)(ptr); \
+ (void)(size); \
+ } while (false)
+
+#define COMMON_INTERCEPTOR_ENTER(ctx, func, ...) \
+ do { \
+ (void)(ctx); \
+ (void)(func); \
+ } while (false)
+
+#define COMMON_INTERCEPTOR_DIR_ACQUIRE(ctx, path) \
+ do { \
+ (void)(ctx); \
+ (void)(path); \
+ } while (false)
+
+#define COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd) \
+ do { \
+ (void)(ctx); \
+ (void)(fd); \
+ } while (false)
+
+#define COMMON_INTERCEPTOR_FD_RELEASE(ctx, fd) \
+ do { \
+ (void)(ctx); \
+ (void)(fd); \
+ } while (false)
+
+#define COMMON_INTERCEPTOR_FD_SOCKET_ACCEPT(ctx, fd, newfd) \
+ do { \
+ (void)(ctx); \
+ (void)(fd); \
+ (void)(newfd); \
+ } while (false)
+
+#define COMMON_INTERCEPTOR_SET_THREAD_NAME(ctx, name) \
+ do { \
+ (void)(ctx); \
+ (void)(name); \
+ } while (false)
+
+#define COMMON_INTERCEPTOR_SET_PTHREAD_NAME(ctx, thread, name) \
+ do { \
+ (void)(ctx); \
+ (void)(thread); \
+ (void)(name); \
+ } while (false)
+
+#define COMMON_INTERCEPTOR_BLOCK_REAL(name) \
+ do { \
+ (void)(name); \
+ } while (false)
+
+#define COMMON_INTERCEPTOR_MEMMOVE_IMPL(ctx, to, from, size) \
+ do { \
+ (void)(ctx); \
+ (void)(to); \
+ (void)(from); \
+ (void)(size); \
+ } while (false)
+
+#define COMMON_INTERCEPTOR_MEMCPY_IMPL(ctx, to, from, size) \
+ do { \
+ (void)(ctx); \
+ (void)(to); \
+ (void)(from); \
+ (void)(size); \
+ } while (false)
+
+#define COMMON_INTERCEPTOR_MEMSET_IMPL(ctx, block, c, size) \
+ do { \
+ (void)(ctx); \
+ (void)(block); \
+ (void)(c); \
+ (void)(size); \
+ } while (false)
+
+#define COMMON_INTERCEPTOR_STRERROR() \
+ do { \
+ } while (false)
+
+#define COMMON_INTERCEPT_FUNCTION(name) \
+ do { \
+ (void)(name); \
+ } while (false)
+
+#include "sanitizer_common/sanitizer_common_interceptors.inc"
+
struct ThreadStartArg {
__sanitizer_sigset_t starting_sigset_;
};
@@ -318,6 +414,10 @@ void InitializeInterceptors() {
static int inited = 0;
CHECK_EQ(inited, 0);
+ (void)(InitializeCommonInterceptors);
+ (void)(read_iovec);
+ (void)(write_iovec);
+
# if HWASAN_WITH_INTERCEPTORS
# if defined(__linux__)
INTERCEPT_FUNCTION(__libc_longjmp);
diff --git a/compiler-rt/lib/hwasan/hwasan_platform_interceptors.h b/compiler-rt/lib/hwasan/hwasan_platform_interceptors.h
index 93957443353a..853cf8bdd92e 100644
--- a/compiler-rt/lib/hwasan/hwasan_platform_interceptors.h
+++ b/compiler-rt/lib/hwasan/hwasan_platform_interceptors.h
@@ -252,6 +252,7 @@
#undef SANITIZER_INTERCEPT_ALIGNED_ALLOC
#undef SANITIZER_INTERCEPT_MALLOC_USABLE_SIZE
#undef SANITIZER_INTERCEPT_MCHECK_MPROBE
+#undef SANITIZER_INTERCEPT_WCSLEN
#undef SANITIZER_INTERCEPT_WCSCAT
#undef SANITIZER_INTERCEPT_WCSDUP
#undef SANITIZER_INTERCEPT_SIGNAL_AND_SIGACTION
@@ -580,6 +581,7 @@
#define SANITIZER_INTERCEPT_ALIGNED_ALLOC 0
#define SANITIZER_INTERCEPT_MALLOC_USABLE_SIZE 0
#define SANITIZER_INTERCEPT_MCHECK_MPROBE 0
+#define SANITIZER_INTERCEPT_WCSLEN 0
#define SANITIZER_INTERCEPT_WCSCAT 0
#define SANITIZER_INTERCEPT_WCSDUP 0
#define SANITIZER_INTERCEPT_SIGNAL_AND_SIGACTION 0
More information about the llvm-commits
mailing list