diff options
author | Jake Burkholder <jake@FreeBSD.org> | 2000-11-22 07:42:04 +0000 |
---|---|---|
committer | Jake Burkholder <jake@FreeBSD.org> | 2000-11-22 07:42:04 +0000 |
commit | 553629ebc915f2377f1f2ce1bf02349db973e5ec (patch) | |
tree | 710e5dfc75aebdd883e2714518ecbe82c1ef2cd9 /sys/kern/kern_fork.c | |
parent | 8707b6f032bff12aedc08e6746078a12bc9fbbf0 (diff) | |
download | src-553629ebc915f2377f1f2ce1bf02349db973e5ec.tar.gz src-553629ebc915f2377f1f2ce1bf02349db973e5ec.zip |
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
Notes
Notes:
svn path=/head/; revision=69022
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r-- | sys/kern/kern_fork.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 70d883cca900..55324c6c3a07 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, |