summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2006-07-21 20:28:56 +0000
committerjhb <jhb@FreeBSD.org>2006-07-21 20:28:56 +0000
commit6370253bdc1d9199f89dc3a29376633daec69c12 (patch)
tree8890696d2d43773fe1ec413fb65e06b7a0e1103f /sys/compat
parent480dbd17c4a6d6e059cb591497f3fd19bcec978d (diff)
downloadFreeBSD-src-6370253bdc1d9199f89dc3a29376633daec69c12.zip
FreeBSD-src-6370253bdc1d9199f89dc3a29376633daec69c12.tar.gz
Add conditional VFS Giant locking to svr4_sys_fchroot() and mark it MPSAFE.
Also, call change_dir() instead of doing part of it inline (this now adds a mac_check_vnode_chdir() call) to match fchdir() and call mac_check_vnode_chroot() to match chroot(). Also, use the change_root() function to do the actual change root to match chroot(). Reviewed by: rwatson
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/svr4/svr4_misc.c40
-rw-r--r--sys/compat/svr4/syscalls.master2
2 files changed, 22 insertions, 20 deletions
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c
index fea3608..6701cf8 100644
--- a/sys/compat/svr4/svr4_misc.c
+++ b/sys/compat/svr4/svr4_misc.c
@@ -606,34 +606,36 @@ svr4_sys_fchroot(td, uap)
struct svr4_sys_fchroot_args *uap;
{
struct filedesc *fdp = td->td_proc->p_fd;
- struct vnode *vp, *vpold;
+ struct vnode *vp;
struct file *fp;
- int error;
+ int error, vfslocked;
if ((error = suser(td)) != 0)
return error;
if ((error = getvnode(fdp, uap->fd, &fp)) != 0)
return error;
vp = fp->f_vnode;
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
- if (vp->v_type != VDIR)
- error = ENOTDIR;
- else
- error = VOP_ACCESS(vp, VEXEC, td->td_ucred, td);
- VOP_UNLOCK(vp, 0, td);
- if (error) {
- fdrop(fp, td);
- return error;
- }
VREF(vp);
- FILEDESC_LOCK_FAST(fdp);
- vpold = fdp->fd_rdir;
- fdp->fd_rdir = vp;
- FILEDESC_UNLOCK_FAST(fdp);
- if (vpold != NULL)
- vrele(vpold);
fdrop(fp, td);
- return 0;
+ vfslocked = VFS_LOCK_GIANT(vp->v_mount);
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
+ error = change_dir(vp, td);
+ if (error)
+ goto fail;
+#ifdef MAC
+ error = mac_check_vnode_chroot(td->td_ucred, vp);
+ if (error)
+ goto fail;
+#endif
+ VOP_UNLOCK(vp, 0, td);
+ error = change_root(vp, td);
+ vrele(vp);
+ VFS_UNLOCK_GIANT(vfslocked);
+ return (error);
+fail:
+ vput(vp);
+ VFS_UNLOCK_GIANT(vfslocked);
+ return (error);
}
diff --git a/sys/compat/svr4/syscalls.master b/sys/compat/svr4/syscalls.master
index a5d6a94..b407c12 100644
--- a/sys/compat/svr4/syscalls.master
+++ b/sys/compat/svr4/syscalls.master
@@ -250,7 +250,7 @@
150 AUE_NULL UNIMPL notused
151 AUE_NULL UNIMPL notused
152 AUE_NULL UNIMPL modctl
-153 AUE_NULL STD { int svr4_sys_fchroot(int fd); }
+153 AUE_NULL MSTD { int svr4_sys_fchroot(int fd); }
154 AUE_NULL MSTD { int svr4_sys_utimes(char *path, \
struct timeval *tptr); }
155 AUE_NULL MSTD { int svr4_sys_vhangup(void); }
OpenPOWER on IntegriCloud