svn commit: r196197 - in stable/7/sys: . contrib/pf fs/unionfs kern
John Baldwin
jhb at FreeBSD.org
Thu Aug 13 17:51:27 UTC 2009
Author: jhb
Date: Thu Aug 13 17:51:26 2009
New Revision: 196197
URL: http://svn.freebsd.org/changeset/base/196197
Log:
MFC: Fix some LORs between vnode locks and filedescriptor table locks.
- Don't grab the filedesc lock just to read fd_cmask.
- Drop vnode locks earlier when mounting the root filesystem and before
sanitizing stdin/out/err file descriptors during execve().
Modified:
stable/7/sys/ (props changed)
stable/7/sys/contrib/pf/ (props changed)
stable/7/sys/fs/unionfs/union_subr.c
stable/7/sys/kern/kern_exec.c
stable/7/sys/kern/vfs_mount.c
stable/7/sys/kern/vfs_syscalls.c
Modified: stable/7/sys/fs/unionfs/union_subr.c
==============================================================================
--- stable/7/sys/fs/unionfs/union_subr.c Thu Aug 13 17:09:45 2009 (r196196)
+++ stable/7/sys/fs/unionfs/union_subr.c Thu Aug 13 17:51:26 2009 (r196197)
@@ -488,9 +488,7 @@ unionfs_create_uppervattr_core(struct un
}
break;
default: /* UNIONFS_TRADITIONAL */
- FILEDESC_SLOCK(td->td_proc->p_fd);
uva->va_mode = 0777 & ~td->td_proc->p_fd->fd_cmask;
- FILEDESC_SUNLOCK(td->td_proc->p_fd);
uva->va_uid = ump->um_uid;
uva->va_gid = ump->um_gid;
break;
Modified: stable/7/sys/kern/kern_exec.c
==============================================================================
--- stable/7/sys/kern/kern_exec.c Thu Aug 13 17:09:45 2009 (r196196)
+++ stable/7/sys/kern/kern_exec.c Thu Aug 13 17:51:26 2009 (r196197)
@@ -615,8 +615,8 @@ interpret:
* allocate memory, so temporarily drop the process lock.
*/
PROC_UNLOCK(p);
- setugidsafety(td);
VOP_UNLOCK(imgp->vp, 0, td);
+ setugidsafety(td);
error = fdcheckstd(td);
vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY, td);
if (error != 0)
Modified: stable/7/sys/kern/vfs_mount.c
==============================================================================
--- stable/7/sys/kern/vfs_mount.c Thu Aug 13 17:09:45 2009 (r196196)
+++ stable/7/sys/kern/vfs_mount.c Thu Aug 13 17:51:26 2009 (r196197)
@@ -1083,9 +1083,10 @@ vfs_domount(
vfs_event_signal(NULL, VQ_MOUNT, 0);
if (VFS_ROOT(mp, LK_EXCLUSIVE, &newdp, td))
panic("mount: lost mount");
- mountcheckdirs(vp, newdp);
- vput(newdp);
+ VOP_UNLOCK(newdp, 0, td);
VOP_UNLOCK(vp, 0, td);
+ mountcheckdirs(vp, newdp);
+ vrele(newdp);
if ((mp->mnt_flag & MNT_RDONLY) == 0)
error = vfs_allocate_syncvnode(mp);
vfs_unbusy(mp, td);
@@ -1468,8 +1469,10 @@ set_rootvnode(struct thread *td)
if (VFS_ROOT(TAILQ_FIRST(&mountlist), LK_EXCLUSIVE, &rootvnode, td))
panic("Cannot find root vnode");
+ VOP_UNLOCK(rootvnode, 0, td);
+
p = td->td_proc;
- FILEDESC_SLOCK(p->p_fd);
+ FILEDESC_XLOCK(p->p_fd);
if (p->p_fd->fd_cdir != NULL)
vrele(p->p_fd->fd_cdir);
@@ -1481,9 +1484,7 @@ set_rootvnode(struct thread *td)
p->p_fd->fd_rdir = rootvnode;
VREF(rootvnode);
- FILEDESC_SUNLOCK(p->p_fd);
-
- VOP_UNLOCK(rootvnode, 0, td);
+ FILEDESC_XUNLOCK(p->p_fd);
}
/*
Modified: stable/7/sys/kern/vfs_syscalls.c
==============================================================================
--- stable/7/sys/kern/vfs_syscalls.c Thu Aug 13 17:09:45 2009 (r196196)
+++ stable/7/sys/kern/vfs_syscalls.c Thu Aug 13 17:51:26 2009 (r196197)
@@ -1238,10 +1238,8 @@ restart:
return (EEXIST);
} else {
VATTR_NULL(&vattr);
- FILEDESC_SLOCK(td->td_proc->p_fd);
vattr.va_mode = (mode & ALLPERMS) &
~td->td_proc->p_fd->fd_cmask;
- FILEDESC_SUNLOCK(td->td_proc->p_fd);
vattr.va_rdev = dev;
whiteout = 0;
@@ -1351,9 +1349,7 @@ restart:
}
VATTR_NULL(&vattr);
vattr.va_type = VFIFO;
- FILEDESC_SLOCK(td->td_proc->p_fd);
vattr.va_mode = (mode & ALLPERMS) & ~td->td_proc->p_fd->fd_cmask;
- FILEDESC_SUNLOCK(td->td_proc->p_fd);
#ifdef MAC
error = mac_check_vnode_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd,
&vattr);
@@ -1564,9 +1560,7 @@ restart:
goto restart;
}
VATTR_NULL(&vattr);
- FILEDESC_SLOCK(td->td_proc->p_fd);
vattr.va_mode = ACCESSPERMS &~ td->td_proc->p_fd->fd_cmask;
- FILEDESC_SUNLOCK(td->td_proc->p_fd);
#ifdef MAC
vattr.va_type = VLNK;
error = mac_check_vnode_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd,
@@ -3502,9 +3496,7 @@ restart:
}
VATTR_NULL(&vattr);
vattr.va_type = VDIR;
- FILEDESC_SLOCK(td->td_proc->p_fd);
vattr.va_mode = (mode & ACCESSPERMS) &~ td->td_proc->p_fd->fd_cmask;
- FILEDESC_SUNLOCK(td->td_proc->p_fd);
#ifdef MAC
error = mac_check_vnode_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd,
&vattr);
More information about the svn-src-all
mailing list