diff options
author | Derek Bruening <bruening@google.com> | 2016-06-13 21:50:00 +0000 |
---|---|---|
committer | Derek Bruening <bruening@google.com> | 2016-06-13 21:50:00 +0000 |
commit | 2a8f0a92c347dbc714cab40a5c61cf336fa0be18 (patch) | |
tree | bd6fb5ac0bc518fa102a32c37d87dfb4ddc05819 /lib/esan/esan_interceptors.cpp | |
parent | 97a35f8a8e9741e9157c0afdbb48a9db99d8a718 (diff) |
[sanitizer][esan] Add internal_sigaction_syscall
Summary:
Adds a version of sigaction that uses a raw system call, to avoid circular
dependencies and support calling sigaction prior to setting up
interceptors. The new sigaction relies on an assembly sigreturn routine
for its restorer, which is Linux x86_64-only for now.
Uses the new sigaction to initialize the working set tool's shadow fault
handler prior to libc interceptor being set up. This is required to
support instrumentation invoked during interceptor setup, which happens
with an instrumented tcmalloc or other allocator compiled with esan.
Adds a test that emulates an instrumented allocator.
Reviewers: aizatsky
Subscribers: vitalybuka, tberghammer, zhaoqin, danalbert, kcc, srhines, eugenis, llvm-commits, kubabrecka
Differential Revision: http://reviews.llvm.org/D21083
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@272591 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/esan/esan_interceptors.cpp')
-rw-r--r-- | lib/esan/esan_interceptors.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/esan/esan_interceptors.cpp b/lib/esan/esan_interceptors.cpp index 5d4edb51d..7aefeb664 100644 --- a/lib/esan/esan_interceptors.cpp +++ b/lib/esan/esan_interceptors.cpp @@ -17,6 +17,7 @@ #include "interception/interception.h" #include "sanitizer_common/sanitizer_common.h" #include "sanitizer_common/sanitizer_libc.h" +#include "sanitizer_common/sanitizer_linux.h" #include "sanitizer_common/sanitizer_stacktrace.h" using namespace __esan; // NOLINT @@ -397,6 +398,11 @@ INTERCEPTOR(int, sigaction, int signum, const struct sigaction *act, // This is required to properly use internal_sigaction. namespace __sanitizer { int real_sigaction(int signum, const void *act, void *oldact) { + if (REAL(sigaction) == nullptr) { + // With an instrumented allocator, this is called during interceptor init + // and we need a raw syscall solution. + return internal_sigaction_syscall(signum, act, oldact); + } return REAL(sigaction)(signum, (const struct sigaction *)act, (struct sigaction *)oldact); } |