Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(943)

Unified Diff: sandbox/linux/seccomp-bpf/trap.cc

Issue 23960006: Linux Sandbox: LOG error if a previous SIGSYS handler exists. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) ||
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698