From owner-svn-src-stable-9@FreeBSD.ORG Thu Mar 15 02:37:15 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3FACC106566B; Thu, 15 Mar 2012 02:37:15 +0000 (UTC) (envelope-from kevlo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 153638FC12; Thu, 15 Mar 2012 02:37:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q2F2bEpE042807; Thu, 15 Mar 2012 02:37:14 GMT (envelope-from kevlo@svn.freebsd.org) Received: (from kevlo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q2F2bER7042805; Thu, 15 Mar 2012 02:37:14 GMT (envelope-from kevlo@svn.freebsd.org) Message-Id: <201203150237.q2F2bER7042805@svn.freebsd.org> From: Kevin Lo Date: Thu, 15 Mar 2012 02:37:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r232995 - stable/9/sys/fs/ntfs X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Mar 2012 02:37:15 -0000 Author: kevlo Date: Thu Mar 15 02:37:14 2012 New Revision: 232995 URL: http://svn.freebsd.org/changeset/base/232995 Log: MFC r232099: Check if the user has necessary permissions on the device Modified: stable/9/sys/fs/ntfs/ntfs_vfsops.c Directory Properties: stable/9/sys/fs/ntfs/ (props changed) Modified: stable/9/sys/fs/ntfs/ntfs_vfsops.c ============================================================================== --- stable/9/sys/fs/ntfs/ntfs_vfsops.c Thu Mar 15 01:43:44 2012 (r232994) +++ stable/9/sys/fs/ntfs/ntfs_vfsops.c Thu Mar 15 02:37:14 2012 (r232995) @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -150,13 +151,16 @@ static const char *ntfs_opts[] = { }; static int -ntfs_mount (struct mount *mp) +ntfs_mount(struct mount *mp) { - int err = 0, error; - struct vnode *devvp; + int err = 0, error; + accmode_t accmode; + struct vnode *devvp; struct nameidata ndp; + struct thread *td; char *from; + td = curthread; if (vfs_filteropt(mp->mnt_optnew, ntfs_opts)) return (EINVAL); @@ -183,7 +187,7 @@ ntfs_mount (struct mount *mp) * Not an update, or updating the name: look up the name * and verify that it refers to a sensible block device. */ - NDINIT(&ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, from, curthread); + NDINIT(&ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, from, td); err = namei(&ndp); if (err) { /* can't get devvp!*/ @@ -197,6 +201,21 @@ ntfs_mount (struct mount *mp) return (err); } + /* + * If mount by non-root, then verify that user has necessary + * permissions on the device. + */ + accmode = VREAD; + if ((mp->mnt_flag & MNT_RDONLY) == 0) + accmode |= VWRITE; + err = VOP_ACCESS(devvp, accmode, td->td_ucred, td); + if (err) + err = priv_check(td, PRIV_VFS_MOUNT_PERM); + if (err) { + vput(devvp); + return (err); + } + if (mp->mnt_flag & MNT_UPDATE) { #if 0 /* @@ -230,7 +249,7 @@ ntfs_mount (struct mount *mp) /* Save "mounted from" info for mount point (NULL pad)*/ vfs_mountedfrom(mp, from); - err = ntfs_mountfs(devvp, mp, curthread); + err = ntfs_mountfs(devvp, mp, td); } if (err) { vrele(devvp); @@ -243,7 +262,7 @@ error_1: /* no state to back out*/ /* XXX: missing NDFREE(&ndp, ...) */ success: - return(err); + return (err); } /*