Date: Fri, 14 Jul 2006 12:05:02 -0400 From: John Baldwin <jhb@freebsd.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: Re: PERFORCE change 101567 for review Message-ID: <200607141205.02412.jhb@freebsd.org> In-Reply-To: <200607141601.k6EG1TJf002705@repoman.freebsd.org> References: <200607141601.k6EG1TJf002705@repoman.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 14 July 2006 12:01, John Baldwin wrote: > http://perforce.freebsd.org/chv.cgi?CH=101567 > > Change 101567 by jhb@jhb_mutex on 2006/07/14 16:01:09 > > Use change_dir() in fchdir() instead of duplicating the logic. This submit also changes svr4_sys_fchroot() to use change_dir() and change_root() and add conditional VFS Giant locking and mark it MPSAFE. It also adds audit stuff and I need to get Robert to review it. > Affected files ... > > .. //depot/projects/smpng/sys/compat/svr4/svr4_misc.c#50 edit > .. //depot/projects/smpng/sys/compat/svr4/syscalls.master#18 edit > .. //depot/projects/smpng/sys/kern/vfs_syscalls.c#111 edit > > Differences ... > > ==== //depot/projects/smpng/sys/compat/svr4/svr4_misc.c#50 (text+ko) ==== > > @@ -606,34 +606,31 @@ > 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; > + AUDIT_ARG(fd, uap->fd); > if ((error = getvnode(fdp, uap->fd, &fp)) != 0) > return error; > vp = fp->f_vnode; > + VREF(vp); > + fdrop(fp, td); > + vfslocked = VFS_LOCK_GIANT(vp->v_mount); > 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); > + AUDIT_ARG(vnode, vp, ARG_VNODE1); > + error = change_dir(vp, td); > +#ifdef MAC > + if (error == 0) > + error = mac_check_vnode_chroot(td->td_ucred, vp); > +#endif > 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; > + if (error == 0) > + error = change_root(vp, td); > + VFS_UNLOCK_GIANT(vfslocked); > + return (error); > } > > > > ==== //depot/projects/smpng/sys/compat/svr4/syscalls.master#18 (text+ko) ==== > > @@ -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); } > > ==== //depot/projects/smpng/sys/kern/vfs_syscalls.c#111 (text+ko) ==== > > @@ -697,14 +697,7 @@ > vfslocked = VFS_LOCK_GIANT(vp->v_mount); > vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); > AUDIT_ARG(vnode, vp, ARG_VNODE1); > - if (vp->v_type != VDIR) > - error = ENOTDIR; > -#ifdef MAC > - else if ((error = mac_check_vnode_chdir(td->td_ucred, vp)) != 0) { > - } > -#endif > - else > - error = VOP_ACCESS(vp, VEXEC, td->td_ucred, td); > + error = change_dir(vp, td); > while (!error && (mp = vp->v_mountedhere) != NULL) { > int tvfslocked; > if (vfs_busy(mp, 0, 0, td)) > -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607141205.02412.jhb>