Commit 1fd8cbba authored by hidehiko's avatar hidehiko Committed by Commit bot

Re-enable Trap.SigSysAction test under tsan.

The reason of Trap.SigSysAction failure under TSAN was identified,
which was;
TSAN intercepts sigaction(), similar to MSAN. So, direct syscall
breaks its assumption. Fallback to sigaction() on TSAN.

TEST=Ran bots with tsan. Ran the failure test case with tsan=1 locally.
BUG=481297

Review URL: https://codereview.chromium.org/1103263003

Cr-Commit-Position: refs/heads/master@{#327216}
parent ffdf17b0
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
namespace sandbox { namespace sandbox {
namespace { namespace {
#if !defined(THREAD_SANITIZER)
SANDBOX_TEST_ALLOW_NOISE(Trap, SigSysAction) { SANDBOX_TEST_ALLOW_NOISE(Trap, SigSysAction) {
// This creates a global Trap instance, and registers the signal handler // This creates a global Trap instance, and registers the signal handler
// (Trap::SigSysAction). // (Trap::SigSysAction).
...@@ -24,7 +23,6 @@ SANDBOX_TEST_ALLOW_NOISE(Trap, SigSysAction) { ...@@ -24,7 +23,6 @@ SANDBOX_TEST_ALLOW_NOISE(Trap, SigSysAction) {
// "Unexpected SIGSYS received." so it is necessary to allow the noise. // "Unexpected SIGSYS received." so it is necessary to allow the noise.
raise(SIGSYS); raise(SIGSYS);
} }
#endif
} // namespace } // namespace
} // namespace sandbox } // namespace sandbox
...@@ -148,18 +148,25 @@ int sys_sigprocmask(int how, const sigset_t* set, decltype(nullptr) oldset) { ...@@ -148,18 +148,25 @@ int sys_sigprocmask(int how, const sigset_t* set, decltype(nullptr) oldset) {
sizeof(linux_value)); sizeof(linux_value));
} }
#if defined(MEMORY_SANITIZER) || \ #if defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) || \
(defined(ARCH_CPU_X86_64) && defined(__GNUC__) && !defined(__clang__)) (defined(ARCH_CPU_X86_64) && !defined(__clang__))
// If MEMORY_SANITIZER is enabled, it is necessary to call sigaction() here, // If MEMORY_SANITIZER or THREAD_SANITIZER is enabled, it is necessary to call
// rather than the direct syscall (sys_sigaction() defined by ourselves). // sigaction() here, rather than the direct syscall (sys_sigaction() defined
// It is because, if MEMORY_SANITIZER is enabled, sigaction is wrapped, and // by ourselves).
// |act->sa_handler| is injected in order to unpoisonize the memory passed via // It is because, if MEMORY_SANITIZER or THREAD_SANITIZER is enabled, sigaction
// callback's arguments. Please see msan_interceptors.cc for more details. // is wrapped, and |act->sa_handler| is injected in order to unpoisonize the
// So, if the direct syscall is used, as MEMORY_SANITIZER does not know about // memory passed via callback's arguments for MEMORY_SANITIZER, or handle
// it, sigaction() invocation in other places would be broken (in more precise, // signals to check thread consistency for THREAD_SANITIZER. Please see
// returned |oldact| would have a broken |sa_handler| callback). // msan_interceptors.cc and tsan_interceptors.cc for more details.
// So, specifically, if MEMORY_SANITIZER is enabled while the direct syscall is
// used, as MEMORY_SANITIZER does not know about it, sigaction() invocation in
// other places would be broken (in more precise, returned |oldact| would have
// a broken |sa_handler| callback).
// Practically, it would break NaCl's signal handler installation. // Practically, it would break NaCl's signal handler installation.
// cf) native_client/src/trusted/service_runtime/linux/nacl_signal.c. // cf) native_client/src/trusted/service_runtime/linux/nacl_signal.c.
// As for THREAD_SANITIZER, the intercepted signal handlers are processed more
// in other libc functions' interceptors (such as for raise()), so that it
// would not work properly.
// //
// Also on x86_64 architecture, we need naked function for rt_sigreturn. // Also on x86_64 architecture, we need naked function for rt_sigreturn.
// However, there is no simple way to define it with GCC. Note that the body // However, there is no simple way to define it with GCC. Note that the body
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment