summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-04-03 13:15:42 -0400
committerRich Felker <dalias@aerifal.cx>2011-04-03 13:15:42 -0400
commit66def4e776a0c6d68559309aa043163f77b148a5 (patch)
treecea9fd1829b26fd47ee4ae6333da5db44eb2c47a
parent1ad049b7b60b2c1704b8bb5b94ee4f95d7540b3a (diff)
downloadmusl-66def4e776a0c6d68559309aa043163f77b148a5.tar.gz
musl-66def4e776a0c6d68559309aa043163f77b148a5.tar.bz2
musl-66def4e776a0c6d68559309aa043163f77b148a5.tar.xz
musl-66def4e776a0c6d68559309aa043163f77b148a5.zip
block all signals during rsyscall
otherwise a signal handler could see an inconsistent and nonconformant program state where different threads have different uids/gids.
-rw-r--r--src/thread/pthread_create.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c
index 344b39f8..cdf36ff2 100644
--- a/src/thread/pthread_create.c
+++ b/src/thread/pthread_create.c
@@ -85,7 +85,7 @@ static void rsyscall_handler(int sig, siginfo_t *si, void *ctx)
/* Threads which have already decremented themselves from the
* thread count must not increment rs.cnt or otherwise act. */
if (self->dead) {
- sigaddset(&((ucontext_t *)ctx)->uc_sigmask, SIGSYSCALL);
+ sigfillset(&((ucontext_t *)ctx)->uc_sigmask);
return;
}
@@ -151,13 +151,18 @@ static void init_threads()
libc.lockfile = __lockfile;
libc.cancelpt = cancelpt;
libc.rsyscall = rsyscall;
+
+ sigfillset(&sa.sa_mask);
+ sa.sa_sigaction = rsyscall_handler;
+ __libc_sigaction(SIGSYSCALL, &sa, 0);
+
+ sigemptyset(&sa.sa_mask);
sa.sa_sigaction = cancel_handler;
__libc_sigaction(SIGCANCEL, &sa, 0);
+
sigaddset(&sa.sa_mask, SIGSYSCALL);
sigaddset(&sa.sa_mask, SIGCANCEL);
- sa.sa_sigaction = rsyscall_handler;
- __libc_sigaction(SIGSYSCALL, &sa, 0);
- sigprocmask(SIG_UNBLOCK, &sa.sa_mask, 0);
+ __libc_sigprocmask(SIG_UNBLOCK, &sa.sa_mask, 0);
}
static int start(void *p)