mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-31 16:57:10 +00:00
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
This commit is contained in:
parent
b04aff773e
commit
52d639a953
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=160557
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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); }
|
||||
|
Loading…
Reference in New Issue
Block a user