summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_fork.c
diff options
context:
space:
mode:
authorjake <jake@FreeBSD.org>2000-11-22 07:42:04 +0000
committerjake <jake@FreeBSD.org>2000-11-22 07:42:04 +0000
commit0c0be4e82677a2d8fb49b7a70676bf359e7360b0 (patch)
treea0c32260edfde6d861e66b11172147608684043e /sys/kern/kern_fork.c
parent1b544875743d53491a096b0c757bf30ce73bb83b (diff)
downloadFreeBSD-src-0c0be4e82677a2d8fb49b7a70676bf359e7360b0.zip
FreeBSD-src-0c0be4e82677a2d8fb49b7a70676bf359e7360b0.tar.gz
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
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r--sys/kern/kern_fork.c14
1 files changed, 8 insertions, 6 deletions
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,
OpenPOWER on IntegriCloud