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..33271e28a479a2be9d09cd829e1e9e23e3e9e5f1 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) { |
+ 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; |
+ 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"; |
+ } |
+ |
// Unmask SIGSYS |
sigset_t mask; |
if (sigemptyset(&mask) || |