Skip to content

Commit 743f1c2

Browse files
authored
Revert "[sanitizer] Add cloak_sanitizer_signal_handlers runtime option (#162746)"
This reverts commit 812a225.
1 parent 9bcf8f0 commit 743f1c2

File tree

7 files changed

+2
-168
lines changed

7 files changed

+2
-168
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_common.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,6 @@ void ReportDeadlySignal(const SignalContext &sig, u32 tid,
390390
void SetAlternateSignalStack();
391391
void UnsetAlternateSignalStack();
392392

393-
bool IsSignalHandlerFromSanitizer(int signum);
394-
bool SetSignalHandlerFromSanitizer(int signum, bool new_state);
395-
396393
// Construct a one-line string:
397394
// SUMMARY: SanitizerToolName: error_message
398395
// and pass it to __sanitizer_report_error_summary.

compiler-rt/lib/sanitizer_common/sanitizer_flags.inc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,6 @@ COMMON_FLAG(HandleSignalMode, handle_sigfpe, kHandleSignalYes,
113113
COMMON_FLAG(bool, allow_user_segv_handler, true,
114114
"Deprecated. True has no effect, use handle_sigbus=1. If false, "
115115
"handle_*=1 will be upgraded to handle_*=2.")
116-
COMMON_FLAG(bool, cloak_sanitizer_signal_handlers, false,
117-
"If set, signal/sigaction will pretend that sanitizers did not "
118-
"preinstall any signal handlers. If the user subsequently installs "
119-
"a signal handler, this will disable cloaking for the respective "
120-
"signal.")
121116
COMMON_FLAG(bool, use_sigaltstack, true,
122117
"If set, uses alternate stack for signal handling.")
123118
COMMON_FLAG(bool, detect_deadlocks, true,

compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ typedef void (*sa_sigaction_t)(int, siginfo_t *, void *);
4747

4848
namespace __sanitizer {
4949

50-
static atomic_uint8_t signal_handler_is_from_sanitizer[64];
51-
5250
u32 GetUid() {
5351
return getuid();
5452
}
@@ -212,20 +210,6 @@ void UnsetAlternateSignalStack() {
212210
UnmapOrDie(oldstack.ss_sp, oldstack.ss_size);
213211
}
214212

215-
bool IsSignalHandlerFromSanitizer(int signum) {
216-
return atomic_load(&signal_handler_is_from_sanitizer[signum],
217-
memory_order_relaxed);
218-
}
219-
220-
bool SetSignalHandlerFromSanitizer(int signum, bool new_state) {
221-
if (signum < 0 || static_cast<unsigned>(signum) >=
222-
ARRAY_SIZE(signal_handler_is_from_sanitizer))
223-
return false;
224-
225-
return atomic_exchange(&signal_handler_is_from_sanitizer[signum], new_state,
226-
memory_order_relaxed);
227-
}
228-
229213
static void MaybeInstallSigaction(int signum,
230214
SignalHandlerType handler) {
231215
if (GetHandleSignalMode(signum) == kHandleSignalNo) return;
@@ -239,9 +223,6 @@ static void MaybeInstallSigaction(int signum,
239223
if (common_flags()->use_sigaltstack) sigact.sa_flags |= SA_ONSTACK;
240224
CHECK_EQ(0, internal_sigaction(signum, &sigact, nullptr));
241225
VReport(1, "Installed the sigaction for signal %d\n", signum);
242-
243-
if (common_flags()->cloak_sanitizer_signal_handlers)
244-
SetSignalHandlerFromSanitizer(signum, true);
245226
}
246227

247228
void InstallDeadlySignalHandlers(SignalHandlerType handler) {

compiler-rt/lib/sanitizer_common/sanitizer_signal_interceptors.inc

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ using namespace __sanitizer;
4545
INTERCEPTOR(uptr, bsd_signal, int signum, uptr handler) {
4646
SIGNAL_INTERCEPTOR_ENTER();
4747
if (GetHandleSignalMode(signum) == kHandleSignalExclusive) return 0;
48-
49-
// TODO: support cloak_sanitizer_signal_handlers
5048
SIGNAL_INTERCEPTOR_SIGNAL_IMPL(bsd_signal, signum, handler);
5149
}
5250
#define INIT_BSD_SIGNAL COMMON_INTERCEPT_FUNCTION(bsd_signal)
@@ -58,55 +56,19 @@ INTERCEPTOR(uptr, bsd_signal, int signum, uptr handler) {
5856
INTERCEPTOR(uptr, signal, int signum, uptr handler) {
5957
SIGNAL_INTERCEPTOR_ENTER();
6058
if (GetHandleSignalMode(signum) == kHandleSignalExclusive)
61-
// The user can neither view nor change the signal handler, regardless of
62-
// the cloak_sanitizer_signal_handlers setting. This differs from
63-
// sigaction().
6459
return (uptr) nullptr;
65-
66-
uptr ret = +[](auto signal, int signum, uptr handler) {
67-
SIGNAL_INTERCEPTOR_SIGNAL_IMPL(signal, signum, handler);
68-
}(signal, signum, handler);
69-
70-
if (ret != sig_err && SetSignalHandlerFromSanitizer(signum, false))
71-
// If the user sets a signal handler, it becomes uncloaked, even if they
72-
// reuse a sanitizer's signal handler.
73-
ret = sig_dfl;
74-
75-
return ret;
60+
SIGNAL_INTERCEPTOR_SIGNAL_IMPL(signal, signum, handler);
7661
}
7762
#define INIT_SIGNAL COMMON_INTERCEPT_FUNCTION(signal)
7863

7964
INTERCEPTOR(int, sigaction_symname, int signum,
8065
const __sanitizer_sigaction *act, __sanitizer_sigaction *oldact) {
8166
SIGNAL_INTERCEPTOR_ENTER();
82-
8367
if (GetHandleSignalMode(signum) == kHandleSignalExclusive) {
8468
if (!oldact) return 0;
8569
act = nullptr;
86-
// If cloak_sanitizer_signal_handlers=true, the user can neither view nor
87-
// change the signal handle.
88-
// If false, the user can view but not change the signal handler. This
89-
// differs from signal().
9070
}
91-
92-
int ret = +[](int signum, const __sanitizer_sigaction* act,
93-
__sanitizer_sigaction* oldact) {
94-
SIGNAL_INTERCEPTOR_SIGACTION_IMPL(signum, act, oldact);
95-
}(signum, act, oldact);
96-
97-
if (act) {
98-
if (ret == 0 && SetSignalHandlerFromSanitizer(signum, false)) {
99-
// If the user sets a signal handler, it becomes uncloaked, even if they
100-
// reuse a sanitizer's signal handler.
101-
102-
if (oldact)
103-
oldact->handler = reinterpret_cast<__sanitizer_sighandler_ptr>(sig_dfl);
104-
}
105-
} else if (ret == 0 && oldact && IsSignalHandlerFromSanitizer(signum)) {
106-
oldact->handler = reinterpret_cast<__sanitizer_sighandler_ptr>(sig_dfl);
107-
}
108-
109-
return ret;
71+
SIGNAL_INTERCEPTOR_SIGACTION_IMPL(signum, act, oldact);
11072
}
11173
#define INIT_SIGACTION COMMON_INTERCEPT_FUNCTION(sigaction_symname)
11274

compiler-rt/test/sanitizer_common/TestCases/Linux/allow_user_segv.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
// Flaky errors in debuggerd with "waitpid returned unexpected pid (0)" in logcat.
2424
// UNSUPPORTED: android && i386-target-arch
2525

26-
// Note: this test case is unusual because it retrieves the original
27-
// (ASan-installed) signal handler; thus, it is incompatible with the
28-
// cloak_sanitizer_signal_handlers runtime option.
29-
3026
#include <signal.h>
3127
#include <stdio.h>
3228
#include <stdlib.h>

compiler-rt/test/sanitizer_common/TestCases/Linux/cloak_sigaction.cpp

Lines changed: 0 additions & 51 deletions
This file was deleted.

compiler-rt/test/sanitizer_common/TestCases/Linux/cloak_signal.cpp

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)