summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_fork.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_fork.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_fork.c')
-rw-r--r--sys/kern/kern_fork.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index b701ee936cb..df6ffd8c7a0 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_fork.c,v 1.108 2010/01/14 23:12:11 schwarze Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.109 2010/03/24 23:18:17 tedu Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@@ -414,7 +414,9 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize,
} while (pidtaken(lastpid));
p2->p_pid = lastpid;
+ rw_enter_write(&allproclk);
LIST_INSERT_HEAD(&allproc, p2, p_list);
+ rw_exit_write(&allproclk);
LIST_INSERT_HEAD(PIDHASH(p2->p_pid), p2, p_hash);
LIST_INSERT_HEAD(&p1->p_children, p2, p_sibling);
LIST_INSERT_AFTER(p1, p2, p_pglist);