From 0c0be4e82677a2d8fb49b7a70676bf359e7360b0 Mon Sep 17 00:00:00 2001 From: jake Date: Wed, 22 Nov 2000 07:42:04 +0000 Subject: Protect the following with a lockmgr lock: allproc zombproc pidhashtbl proc.p_list proc.p_hash nextpid Reviewed by: jhb Obtained from: BSD/OS and netbsd --- sys/kern/kern_fork.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'sys/kern/kern_fork.c') diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 70d883c..55324c6 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -287,6 +287,7 @@ fork1(p1, flags, procp) * If RFHIGHPID is set (used during system boot), do not allocate * low-numbered pids. */ + lockmgr(&allproc_lock, LK_EXCLUSIVE, NULL, CURPROC); trypid = nextpid + 1; if (flags & RFHIGHPID) { if (trypid < 10) { @@ -343,12 +344,6 @@ again: } } - p2 = newproc; - p2->p_stat = SIDL; /* protect against others */ - p2->p_pid = trypid; - LIST_INSERT_HEAD(&allproc, p2, p_list); - LIST_INSERT_HEAD(PIDHASH(p2->p_pid), p2, p_hash); - /* * RFHIGHPID does not mess with the nextpid counter during boot. */ @@ -357,6 +352,13 @@ again: else nextpid = trypid; + p2 = newproc; + p2->p_stat = SIDL; /* protect against others */ + p2->p_pid = trypid; + LIST_INSERT_HEAD(&allproc, p2, p_list); + LIST_INSERT_HEAD(PIDHASH(p2->p_pid), p2, p_hash); + lockmgr(&allproc_lock, LK_RELEASE, NULL, CURPROC); + /* * Make a proc table entry for the new process. * Start by zeroing the section of proc that is zero-initialized, -- cgit v1.1