From 19d4244da751ce8223f33a98ff39833f0404cc1e Mon Sep 17 00:00:00 2001 From: visa Date: Wed, 18 Mar 2020 15:48:21 +0000 Subject: 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@ --- sys/kern/kern_exit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sys/kern/kern_exit.c') 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; -- cgit v1.2.3-59-g8ed1b