diff options
author | Vitaly Buka <vitalybuka@google.com> | 2017-11-09 22:48:54 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2017-11-09 22:48:54 +0000 |
commit | 4fa4ebc62392de210e22dc5064699957676c4c8f (patch) | |
tree | 5671f829511daa91828697d63fd9c8e554b653fa /lib | |
parent | e69cf7acdc4881a769238cff4f495bec8a8b2f8e (diff) |
[sanitizer] Allow sanitizers to redefine implementation of signal interceptors
Reviewers: eugenis
Subscribers: llvm-commits, kubamracek
Differential Revision: https://reviews.llvm.org/D39870
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317843 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/asan/asan_interceptors.h | 9 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_signal_interceptors.inc | 32 |
2 files changed, 30 insertions, 11 deletions
diff --git a/lib/asan/asan_interceptors.h b/lib/asan/asan_interceptors.h index 7728b356a..87727467b 100644 --- a/lib/asan/asan_interceptors.h +++ b/lib/asan/asan_interceptors.h @@ -19,6 +19,10 @@ #include "interception/interception.h" #include "sanitizer_common/sanitizer_platform_interceptors.h" +namespace __sanitizer { +struct __sanitizer_sigaction; +} + namespace __asan { void InitializeAsanInterceptors(); @@ -106,8 +110,9 @@ DECLARE_REAL(char*, strncpy, char *to, const char *from, uptr size) DECLARE_REAL(uptr, strnlen, const char *s, uptr maxlen) DECLARE_REAL(char*, strstr, const char *s1, const char *s2) struct sigaction; -DECLARE_REAL(int, sigaction, int signum, const struct sigaction *act, - struct sigaction *oldact) +DECLARE_REAL(int, sigaction, int signum, + const __sanitizer::__sanitizer_sigaction *act, + __sanitizer::__sanitizer_sigaction *oldact) #if !SANITIZER_MAC #define ASAN_INTERCEPT_FUNC(name) \ diff --git a/lib/sanitizer_common/sanitizer_signal_interceptors.inc b/lib/sanitizer_common/sanitizer_signal_interceptors.inc index f38e1b96e..ea660710c 100644 --- a/lib/sanitizer_common/sanitizer_signal_interceptors.inc +++ b/lib/sanitizer_common/sanitizer_signal_interceptors.inc @@ -18,10 +18,24 @@ using namespace __sanitizer; +namespace __sanitizer { +struct __sanitizer_sigaction; +} + +#ifndef SIGNAL_INTERCEPTOR_SIGNAL_IMPL +#define SIGNAL_INTERCEPTOR_SIGNAL_IMPL(func, signum, handler) \ + { return REAL(func)(signum, handler); } +#endif + +#ifndef SIGNAL_INTERCEPTOR_SIGACTION_IMPL +#define SIGNAL_INTERCEPTOR_SIGACTION_IMPL(signum, act, oldact) \ + { return REAL(sigaction)(signum, act, oldact); } +#endif + #if SANITIZER_INTERCEPT_BSD_SIGNAL -INTERCEPTOR(void *, bsd_signal, int signum, void *handler) { +INTERCEPTOR(void *, bsd_signal, int signum, uptr handler) { if (GetHandleSignalMode(signum) == kHandleSignalExclusive) return 0; - return REAL(bsd_signal)(signum, handler); + SIGNAL_INTERCEPTOR_SIGNAL_IMPL(bsd_signal, signum, handler); } #define INIT_BSD_SIGNAL COMMON_INTERCEPT_FUNCTION(bsd_signal) #else // SANITIZER_INTERCEPT_BSD_SIGNAL @@ -29,23 +43,23 @@ INTERCEPTOR(void *, bsd_signal, int signum, void *handler) { #endif // SANITIZER_INTERCEPT_BSD_SIGNAL #if SANITIZER_INTERCEPT_SIGNAL_AND_SIGACTION -INTERCEPTOR(void *, signal, int signum, void *handler) { +INTERCEPTOR(void *, signal, int signum, uptr handler) { if (GetHandleSignalMode(signum) == kHandleSignalExclusive) return nullptr; - return REAL(signal)(signum, handler); + SIGNAL_INTERCEPTOR_SIGNAL_IMPL(signal, signum, handler); } #define INIT_SIGNAL COMMON_INTERCEPT_FUNCTION(signal) -INTERCEPTOR(int, sigaction, int signum, const struct sigaction *act, - struct sigaction *oldact) { +INTERCEPTOR(int, sigaction, int signum, const __sanitizer_sigaction *act, + __sanitizer_sigaction *oldact) { if (GetHandleSignalMode(signum) == kHandleSignalExclusive) return 0; - return REAL(sigaction)(signum, act, oldact); + SIGNAL_INTERCEPTOR_SIGACTION_IMPL(signum, act, oldact); } #define INIT_SIGACTION COMMON_INTERCEPT_FUNCTION(sigaction) namespace __sanitizer { int real_sigaction(int signum, const void *act, void *oldact) { - return REAL(sigaction)(signum, (const struct sigaction *)act, - (struct sigaction *)oldact); + return REAL(sigaction)(signum, (const __sanitizer_sigaction *)act, + (__sanitizer_sigaction *)oldact); } } // namespace __sanitizer #else // SANITIZER_INTERCEPT_SIGNAL_AND_SIGACTION |