diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2020-11-16 18:37:07 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2020-11-16 18:37:07 +0000 |
commit | 2ae9b8cb5f4c03f7565afea3d2909c3572b4746f (patch) | |
tree | 84fbf8e4d58e944cb8221822e7f471cbb8da4153 | |
parent | 4b2d38bf6dc91261e0c92cf68fa00f1357ebef3b (diff) |
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.c | 4 |
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); |