summaryrefslogtreecommitdiff
path: root/sys/kern/kern_sched.c
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2018-07-07 15:19:26 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2018-07-07 15:19:26 +0000
commit8057647d9610ac9017742fe97f823b4dc5c40538 (patch)
treea7c1251f0c1d3c5335862b7ac95f5150bfdb722b /sys/kern/kern_sched.c
parent19c8d8ab4c5fd7687547983f4cc64ad0144abe85 (diff)
Release the kernel lock fully on thread exit. This prevents a locking
error that would happen otherwise when a traced and stopped multithreaded process is forced to exit. The error shows up as a kernel panic when WITNESS is enabled. Without WITNESS, the error causes a system hang. sched_exit() has expected that a single KERNEL_UNLOCK() would release the lock completely. That assumption is wrong when an exit happens through the signal tracing logic: sched_exit exit1 single_thread_check single_thread_set issignal <-- KERNEL_LOCK() userret <-- KERNEL_LOCK() syscall The error is a regression of r1.216 of kern_sig.c. Panic reported and fix tested by Laurence Tratt OK mpi@
Diffstat (limited to 'sys/kern/kern_sched.c')
-rw-r--r--sys/kern/kern_sched.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c
index 9de421f037a..4309255ca9d 100644
--- a/sys/kern/kern_sched.c
+++ b/sys/kern/kern_sched.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sched.c,v 1.49 2018/06/30 14:43:36 kettenis Exp $ */
+/* $OpenBSD: kern_sched.c,v 1.50 2018/07/07 15:19:25 visa Exp $ */
/*
* Copyright (c) 2007, 2008 Artur Grabowski <art@openbsd.org>
*
@@ -218,8 +218,11 @@ sched_exit(struct proc *p)
LIST_INSERT_HEAD(&spc->spc_deadproc, p, p_hash);
+#ifdef MULTIPROCESSOR
/* This process no longer needs to hold the kernel lock. */
- KERNEL_UNLOCK();
+ KERNEL_ASSERT_LOCKED();
+ __mp_release_all(&kernel_lock);
+#endif
SCHED_LOCK(s);
idle = spc->spc_idleproc;