Index: sandbox/linux/seccomp-bpf/trap.cc |
diff --git a/sandbox/linux/seccomp-bpf/trap.cc b/sandbox/linux/seccomp-bpf/trap.cc |
index 3c30de35546d89768d79ddb490cfba7635aa6409..40ee61a6f64c78ff8a6f9e8b3d6ee748ecb819a7 100644 |
--- a/sandbox/linux/seccomp-bpf/trap.cc |
+++ b/sandbox/linux/seccomp-bpf/trap.cc |
@@ -61,6 +61,14 @@ void SetIsInSigHandler() { |
} |
} |
+bool IsDefaultSignalAction(const struct sigaction& sa) { |
+ if (sa.sa_flags & SA_SIGINFO || |
+ sa.sa_handler != SIG_DFL) { |
Markus (顧孟勤)
2013/09/05 22:23:25
SIG_IGN is probably also OK, but we can hold off o
jln (very slow on Chromium)
2013/09/05 22:29:05
It'll mostly be for the spurious SIGSYS bug report
|
+ return false; |
+ } |
+ return true; |
+} |
+ |
} // namespace |
namespace playground2 { |
@@ -74,10 +82,16 @@ Trap::Trap() |
struct sigaction sa = { }; |
sa.sa_sigaction = SigSysAction; |
sa.sa_flags = SA_SIGINFO | SA_NODEFER; |
- if (sigaction(SIGSYS, &sa, NULL) < 0) { |
+ struct sigaction old_sa = { }; |
Markus (顧孟勤)
2013/09/05 22:23:25
Why do you need to zero out this structure? I know
jln (very slow on Chromium)
2013/09/05 22:29:05
Done.
|
+ if (sigaction(SIGSYS, &sa, &old_sa) < 0) { |
SANDBOX_DIE("Failed to configure SIGSYS handler"); |
} |
+ if (!IsDefaultSignalAction(old_sa)) { |
+ // TODO(jln): make this FATAL, at least in DEBUG mode. |
+ LOG(ERROR) << "Existing signal handler when trying to install SIGSYS"; |
Markus (顧孟勤)
2013/09/05 22:23:25
It would be nice, if we could actually log what th
jln (very slow on Chromium)
2013/09/05 22:29:05
Yeah, and in the spurious SIGSYS case, it's likely
|
+ } |
+ |
// Unmask SIGSYS |
sigset_t mask; |
if (sigemptyset(&mask) || |