summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exit.c
diff options
context:
space:
mode:
authorvisa <visa@openbsd.org>2020-03-18 15:48:21 +0000
committervisa <visa@openbsd.org>2020-03-18 15:48:21 +0000
commit19d4244da751ce8223f33a98ff39833f0404cc1e (patch)
tree3ecf07e6418cf6d5243b4382eec5946f16007906 /sys/kern/kern_exit.c
parentPlug mem leak in SADB_REGISTER. (diff)
downloadwireguard-openbsd-19d4244da751ce8223f33a98ff39833f0404cc1e.tar.xz
wireguard-openbsd-19d4244da751ce8223f33a98ff39833f0404cc1e.zip
Restart child process scan in dowait4() if single_thread_wait() sleeps.
This ensures that the conditions checked are still in force. The sleep breaks atomicity, allowing another thread to alter the state. single_thread_set() should return immediately after sleep when called from dowait4() because there is no guarantee that the process pr still exists. When called from single_thread_set(), the process is that of the calling thread, which prevents process pr from disappearing. OK anton@, mpi@, claudio@
Diffstat (limited to 'sys/kern/kern_exit.c')
-rw-r--r--sys/kern/kern_exit.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 1ed8f8f3474..66ffad0de02 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exit.c,v 1.187 2020/03/16 11:58:46 mpi Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.188 2020/03/18 15:48:21 visa Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@@ -539,7 +539,8 @@ loop:
(pr->ps_flags & PS_WAITED) == 0 && pr->ps_single &&
pr->ps_single->p_stat == SSTOP &&
(pr->ps_single->p_flag & P_SUSPSINGLE) == 0) {
- single_thread_wait(pr);
+ if (single_thread_wait(pr, 0))
+ goto loop;
atomic_setbits_int(&pr->ps_flags, PS_WAITED);
retval[0] = pr->ps_pid;