Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions compiler-rt/lib/sanitizer_common/sanitizer_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,6 @@ void ReportDeadlySignal(const SignalContext &sig, u32 tid,
void SetAlternateSignalStack();
void UnsetAlternateSignalStack();

bool IsSignalHandlerFromSanitizer(int signum);
bool SetSignalHandlerFromSanitizer(int signum, bool new_state);

// Construct a one-line string:
// SUMMARY: SanitizerToolName: error_message
// and pass it to __sanitizer_report_error_summary.
Expand Down
5 changes: 0 additions & 5 deletions compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,6 @@ COMMON_FLAG(HandleSignalMode, handle_sigfpe, kHandleSignalYes,
COMMON_FLAG(bool, allow_user_segv_handler, true,
"Deprecated. True has no effect, use handle_sigbus=1. If false, "
"handle_*=1 will be upgraded to handle_*=2.")
COMMON_FLAG(bool, cloak_sanitizer_signal_handlers, false,
"If set, signal/sigaction will pretend that sanitizers did not "
"preinstall any signal handlers. If the user subsequently installs "
"a signal handler, this will disable cloaking for the respective "
"signal.")
COMMON_FLAG(bool, use_sigaltstack, true,
"If set, uses alternate stack for signal handling.")
COMMON_FLAG(bool, detect_deadlocks, true,
Expand Down
19 changes: 0 additions & 19 deletions compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ typedef void (*sa_sigaction_t)(int, siginfo_t *, void *);

namespace __sanitizer {

static atomic_uint8_t signal_handler_is_from_sanitizer[64];

u32 GetUid() {
return getuid();
}
Expand Down Expand Up @@ -212,20 +210,6 @@ void UnsetAlternateSignalStack() {
UnmapOrDie(oldstack.ss_sp, oldstack.ss_size);
}

bool IsSignalHandlerFromSanitizer(int signum) {
return atomic_load(&signal_handler_is_from_sanitizer[signum],
memory_order_relaxed);
}

bool SetSignalHandlerFromSanitizer(int signum, bool new_state) {
if (signum < 0 || static_cast<unsigned>(signum) >=
ARRAY_SIZE(signal_handler_is_from_sanitizer))
return false;

return atomic_exchange(&signal_handler_is_from_sanitizer[signum], new_state,
memory_order_relaxed);
}

static void MaybeInstallSigaction(int signum,
SignalHandlerType handler) {
if (GetHandleSignalMode(signum) == kHandleSignalNo) return;
Expand All @@ -239,9 +223,6 @@ static void MaybeInstallSigaction(int signum,
if (common_flags()->use_sigaltstack) sigact.sa_flags |= SA_ONSTACK;
CHECK_EQ(0, internal_sigaction(signum, &sigact, nullptr));
VReport(1, "Installed the sigaction for signal %d\n", signum);

if (common_flags()->cloak_sanitizer_signal_handlers)
SetSignalHandlerFromSanitizer(signum, true);
}

void InstallDeadlySignalHandlers(SignalHandlerType handler) {
Expand Down
42 changes: 2 additions & 40 deletions compiler-rt/lib/sanitizer_common/sanitizer_signal_interceptors.inc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ using namespace __sanitizer;
INTERCEPTOR(uptr, bsd_signal, int signum, uptr handler) {
SIGNAL_INTERCEPTOR_ENTER();
if (GetHandleSignalMode(signum) == kHandleSignalExclusive) return 0;

// TODO: support cloak_sanitizer_signal_handlers
SIGNAL_INTERCEPTOR_SIGNAL_IMPL(bsd_signal, signum, handler);
}
#define INIT_BSD_SIGNAL COMMON_INTERCEPT_FUNCTION(bsd_signal)
Expand All @@ -58,55 +56,19 @@ INTERCEPTOR(uptr, bsd_signal, int signum, uptr handler) {
INTERCEPTOR(uptr, signal, int signum, uptr handler) {
SIGNAL_INTERCEPTOR_ENTER();
if (GetHandleSignalMode(signum) == kHandleSignalExclusive)
// The user can neither view nor change the signal handler, regardless of
// the cloak_sanitizer_signal_handlers setting. This differs from
// sigaction().
return (uptr) nullptr;

uptr ret = +[](auto signal, int signum, uptr handler) {
SIGNAL_INTERCEPTOR_SIGNAL_IMPL(signal, signum, handler);
}(signal, signum, handler);

if (ret != sig_err && SetSignalHandlerFromSanitizer(signum, false))
// If the user sets a signal handler, it becomes uncloaked, even if they
// reuse a sanitizer's signal handler.
ret = sig_dfl;

return ret;
SIGNAL_INTERCEPTOR_SIGNAL_IMPL(signal, signum, handler);
}
#define INIT_SIGNAL COMMON_INTERCEPT_FUNCTION(signal)

INTERCEPTOR(int, sigaction_symname, int signum,
const __sanitizer_sigaction *act, __sanitizer_sigaction *oldact) {
SIGNAL_INTERCEPTOR_ENTER();

if (GetHandleSignalMode(signum) == kHandleSignalExclusive) {
if (!oldact) return 0;
act = nullptr;
// If cloak_sanitizer_signal_handlers=true, the user can neither view nor
// change the signal handle.
// If false, the user can view but not change the signal handler. This
// differs from signal().
}

int ret = +[](int signum, const __sanitizer_sigaction* act,
__sanitizer_sigaction* oldact) {
SIGNAL_INTERCEPTOR_SIGACTION_IMPL(signum, act, oldact);
}(signum, act, oldact);

if (act) {
if (ret == 0 && SetSignalHandlerFromSanitizer(signum, false)) {
// If the user sets a signal handler, it becomes uncloaked, even if they
// reuse a sanitizer's signal handler.

if (oldact)
oldact->handler = reinterpret_cast<__sanitizer_sighandler_ptr>(sig_dfl);
}
} else if (ret == 0 && oldact && IsSignalHandlerFromSanitizer(signum)) {
oldact->handler = reinterpret_cast<__sanitizer_sighandler_ptr>(sig_dfl);
}

return ret;
SIGNAL_INTERCEPTOR_SIGACTION_IMPL(signum, act, oldact);
}
#define INIT_SIGACTION COMMON_INTERCEPT_FUNCTION(sigaction_symname)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
// Flaky errors in debuggerd with "waitpid returned unexpected pid (0)" in logcat.
// UNSUPPORTED: android && i386-target-arch

// Note: this test case is unusual because it retrieves the original
// (ASan-installed) signal handler; thus, it is incompatible with the
// cloak_sanitizer_signal_handlers runtime option.

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down

This file was deleted.

46 changes: 0 additions & 46 deletions compiler-rt/test/sanitizer_common/TestCases/Linux/cloak_signal.cpp

This file was deleted.

Loading