summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_prot.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-11-12 18:56:49 +0000
committerjhb <jhb@FreeBSD.org>2001-11-12 18:56:49 +0000
commitc7338726d95c9981686875afc8726078ab7ff821 (patch)
tree6784b34e0d65d632d9d07c0889679e638d222d5f /sys/kern/kern_prot.c
parent0c3e87867faeb5fedd10ede031b2c5573c4154fa (diff)
downloadFreeBSD-src-c7338726d95c9981686875afc8726078ab7ff821.zip
FreeBSD-src-c7338726d95c9981686875afc8726078ab7ff821.tar.gz
Clean up breakage in inferior() I introduced in 1.92 of kern_proc.c:
- Restore inferior() to being iterative rather than recursive. - Assert that the proctree_lock is held in inferior() and change the one caller to get a shared lock of it. This also ensures that we hold the lock after performing the check so the check can't be made invalid out from under us after the check but before we act on it. Requested by: bde
Diffstat (limited to 'sys/kern/kern_prot.c')
-rw-r--r--sys/kern/kern_prot.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c
index 5ffeeb7..9378d48 100644
--- a/sys/kern/kern_prot.c
+++ b/sys/kern/kern_prot.c
@@ -55,6 +55,7 @@
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
+#include <sys/sx.h>
#include <sys/sysproto.h>
#include <sys/malloc.h>
#include <sys/pioctl.h>
@@ -443,6 +444,7 @@ setpgid(td, uap)
mtx_lock(&Giant);
+ sx_slock(&proctree_lock);
if (uap->pid != 0 && uap->pid != curp->p_pid) {
if ((targp = pfind(uap->pid)) == NULL || !inferior(targp)) {
if (targp)
@@ -488,6 +490,7 @@ setpgid(td, uap)
PROC_UNLOCK(targp);
error = enterpgrp(targp, uap->pgid, 0);
done2:
+ sx_sunlock(&proctree_lock);
mtx_unlock(&Giant);
return (error);
}
OpenPOWER on IntegriCloud