From owner-p4-projects@FreeBSD.ORG Fri Jul 14 16:42:56 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id EFF2016A4E5; Fri, 14 Jul 2006 16:42:55 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9E19A16A4E1 for ; Fri, 14 Jul 2006 16:42:55 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id DF9F743D45 for ; Fri, 14 Jul 2006 16:42:54 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k6EGgqMX014388 for ; Fri, 14 Jul 2006 12:42:53 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Perforce Change Reviews Date: Fri, 14 Jul 2006 12:05:02 -0400 User-Agent: KMail/1.9.1 References: <200607141601.k6EG1TJf002705@repoman.freebsd.org> In-Reply-To: <200607141601.k6EG1TJf002705@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200607141205.02412.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Fri, 14 Jul 2006 12:42:53 -0400 (EDT) X-Virus-Scanned: ClamAV 0.87.1/1599/Fri Jul 14 01:35:31 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx Cc: Subject: Re: PERFORCE change 101567 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jul 2006 16:42:56 -0000 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