summaryrefslogtreecommitdiffstats
path: root/sys/fs/procfs
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2007-05-01 12:59:20 +0000
committerdes <des@FreeBSD.org>2007-05-01 12:59:20 +0000
commitcde2655812ddccac97bd2aa162cb2b67257e720c (patch)
tree86a9b3b8a7f6e884ca748fba2d44b82458f9ed67 /sys/fs/procfs
parentf7ee62e6ccc3d3d94b57bcf1504514a4a79e53d9 (diff)
downloadFreeBSD-src-cde2655812ddccac97bd2aa162cb2b67257e720c.zip
FreeBSD-src-cde2655812ddccac97bd2aa162cb2b67257e720c.tar.gz
The process lock is held when procfs_ioctl() is called. Assert that this
is so, and PHOLD the process while sleeping since msleep() will release the lock.
Diffstat (limited to 'sys/fs/procfs')
-rw-r--r--sys/fs/procfs/procfs_ioctl.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/fs/procfs/procfs_ioctl.c b/sys/fs/procfs/procfs_ioctl.c
index ec08da5..8f87eef 100644
--- a/sys/fs/procfs/procfs_ioctl.c
+++ b/sys/fs/procfs/procfs_ioctl.c
@@ -70,7 +70,10 @@ procfs_ioctl(PFS_IOCTL_ARGS)
int ival;
#endif
- PROC_LOCK(p);
+ KASSERT(p != NULL,
+ ("%s() called without a process", __func__));
+ PROC_LOCK_ASSERT(p, MA_OWNED);
+
error = 0;
switch (cmd) {
#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
@@ -124,8 +127,10 @@ procfs_ioctl(PFS_IOCTL_ARGS)
case PIOCWAIT:
while (p->p_step == 0 && (p->p_flag & P_WEXIT) == 0) {
/* sleep until p stops */
+ _PHOLD(p);
error = msleep(&p->p_stype, &p->p_mtx,
PWAIT|PCATCH, "pioctl", 0);
+ _PRELE(p);
if (error != 0)
break;
}
@@ -142,8 +147,10 @@ procfs_ioctl(PFS_IOCTL_ARGS)
case PIOCWAIT32:
while (p->p_step == 0 && (p->p_flag & P_WEXIT) == 0) {
/* sleep until p stops */
+ _PHOLD(p);
error = msleep(&p->p_stype, &p->p_mtx,
PWAIT|PCATCH, "pioctl", 0);
+ _PRELE(p);
if (error != 0)
break;
}
@@ -193,7 +200,6 @@ procfs_ioctl(PFS_IOCTL_ARGS)
default:
error = (ENOTTY);
}
- PROC_UNLOCK(p);
return (error);
}
OpenPOWER on IntegriCloud