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

Unified Diff: src/native_client/src/trusted/service_runtime/posix/nacl_signal.c

Issue 6798008: Add an assertion to check that Chrome/Breakpad does not install a signal handler (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Use %d; amend Windows comment Created 9 years, 8 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
Index: src/native_client/src/trusted/service_runtime/posix/nacl_signal.c
diff --git a/src/native_client/src/trusted/service_runtime/posix/nacl_signal.c b/src/native_client/src/trusted/service_runtime/posix/nacl_signal.c
index 90da4cbd4ff97a3cbb2afbdff2a7f7cf0abf6a1c..dbe189f4a089445e6b1a9f7b13193866d09b19ed 100644
--- a/src/native_client/src/trusted/service_runtime/posix/nacl_signal.c
+++ b/src/native_client/src/trusted/service_runtime/posix/nacl_signal.c
@@ -263,3 +263,29 @@ void NaClSignalHandlerFiniPlatform() {
}
}
}
+
+/*
+ * Check that signal handlers are not registered. We want to
+ * discourage Chrome or libraries from registering signal handlers
+ * themselves, because those signal handlers are often not safe when
+ * triggered from untrusted code. For background, see:
+ * http://code.google.com/p/nativeclient/issues/detail?id=1607
+ */
+void NaClSignalAssertNoHandlers() {
+ int index;
+ for (index = 0; index < SIGNAL_COUNT; index++) {
+ int signum = s_Signals[index];
+ struct sigaction sa;
+ if (sigaction(signum, NULL, &sa) != 0) {
+ NaClLog(LOG_FATAL, "NaClSignalAssertNoHandlers: "
+ "sigaction() call failed\n");
+ }
+ if ((sa.sa_flags & SA_SIGINFO) != 0
+ ? sa.sa_sigaction != NULL
+ : (sa.sa_handler != SIG_DFL && sa.sa_handler != SIG_IGN)) {
+ NaClLog(LOG_FATAL, "NaClSignalAssertNoHandlers: "
+ "A signal handler is registered for signal %d. "
+ "Did Breakpad register this?\n", signum);
+ }
+ }
+}
« no previous file with comments | « src/native_client/src/trusted/service_runtime/nacl_signal.h ('k') | src/native_client/src/trusted/service_runtime/sel_main.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698