| 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);
|
| + }
|
| + }
|
| +}
|
|
|