summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2020-11-16 18:37:06 +0000
committerjsing <jsing@openbsd.org>2020-11-16 18:37:06 +0000
commit00349993d5110f1cb320adcfb59c64d11e261fab (patch)
tree5af47624926e8abe49ba69bf5aed89be4b17924f
parentReenable ikev2_init_auth() return value check. Make sure sa_stateok() (diff)
downloadwireguard-openbsd-00349993d5110f1cb320adcfb59c64d11e261fab.tar.xz
wireguard-openbsd-00349993d5110f1cb320adcfb59c64d11e261fab.zip
Prevent exit status from being clobbered on thread exit.
Ensure that EXIT_NORMAL only runs once by guarding it with PS_EXITING. It was previously possible for EXIT_NORMAL to be run twice, depending on which thread called exit() and the order in which the threads were torn down. This is due to the P_HASSIBLING() check triggering the last thread to run EXIT_NORMAL, even though it may have already been run via an exit() call. ok kettenis@ visa@
-rw-r--r--sys/kern/kern_exit.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 52effcca3e2..a20775419e3 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exit.c,v 1.190 2020/10/15 16:31:11 cheloha Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.191 2020/11/16 18:37:06 jsing Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@@ -140,7 +140,7 @@ exit1(struct proc *p, int xexit, int xsig, int flags)
single_thread_check(p, 0);
}
- if (flags == EXIT_NORMAL) {
+ if (flags == EXIT_NORMAL && !(pr->ps_flags & PS_EXITING)) {
if (pr->ps_pid == 1)
panic("init died (signal %d, exit %d)", xsig, xexit);