summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exit.c
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2010-03-24 23:18:17 +0000
committertedu <tedu@openbsd.org>2010-03-24 23:18:17 +0000
commit848c61ac39fbea5325564efce8fcf0080c29d321 (patch)
treebf424407fe88147c0a693f4f31d0b5b66ae01a97 /sys/kern/kern_exit.c
parentsync (diff)
downloadwireguard-openbsd-848c61ac39fbea5325564efce8fcf0080c29d321.tar.xz
wireguard-openbsd-848c61ac39fbea5325564efce8fcf0080c29d321.zip
Add a rwlock around the filehead and allproc lists, mainly to protect
list walkers in sysctl that can block. As a reward, no more vslock. With some feedback from art, guenther, phessler. ok guenther.
Diffstat (limited to 'sys/kern/kern_exit.c')
-rw-r--r--sys/kern/kern_exit.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 6ce6154908f..3ff122b1621 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exit.c,v 1.89 2009/12/20 23:54:11 guenther Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.90 2010/03/24 23:18:17 tedu Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@@ -248,9 +248,11 @@ exit1(struct proc *p, int rv, int flags)
* deadproc list later (using the p_hash member), and
* wake up the reaper when we do.
*/
+ rw_enter_write(&allproclk);
LIST_REMOVE(p, p_hash);
LIST_REMOVE(p, p_list);
LIST_INSERT_HEAD(&zombproc, p, p_list);
+ rw_exit_write(&allproclk);
/*
* Give orphaned children to init(8).
@@ -564,7 +566,9 @@ proc_zap(struct proc *p)
* Unlink it from its process group and free it.
*/
leavepgrp(p);
+ rw_enter_write(&allproclk);
LIST_REMOVE(p, p_list); /* off zombproc */
+ rw_exit_write(&allproclk);
LIST_REMOVE(p, p_sibling);
/*