Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 04 Aug 2011 15:49:38 -0700
From:      Xin LI <delphij@delphij.net>
To:        Jung-uk Kim <jkim@FreeBSD.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@FreeBSD.org, Martin Matuska <mm@freebsd.org>
Subject:   Re: svn commit: r224614 - head/sys/kern
Message-ID:  <4E3B2202.30205@delphij.net>
In-Reply-To: <201108041746.47551.jkim@FreeBSD.org>
References:  <201108021913.p72JDun2064946@svn.freebsd.org> <201108041746.47551.jkim@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------020907050005030601080603
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 08/04/11 14:46, Jung-uk Kim wrote:
> On Tuesday 02 August 2011 03:13 pm, Martin Matuska wrote:
>> Author: mm Date: Tue Aug  2 19:13:56 2011 New Revision: 224614 URL:
>> http://svn.freebsd.org/changeset/base/224614
>> 
>> Log: For mount, discover f_mntonname from supplied path argument 
>> using vn_fullpath_global(). This fixes f_mntonname if mounting 
>> inside chroot, jail or with relative path as argument.
>> 
>> For unmount in jail, use vn_fullpath_global() to discover global
>> path from supplied path argument. This fixes unmount in jail.
> 
> It seems fdescfs(5) hangs after this commit if the mount point is
> /dev/fd.

Please find attached kib@'s patch that fixes this issue (david wolfskill
and I have both tested individually).

Cheers,
- -- 
Xin LI <delphij@delphij.net>	https://www.delphij.net/
FreeBSD - The Power to Serve!		Live free or die
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (FreeBSD)

iQEcBAEBCAAGBQJOOyIBAAoJEATO+BI/yjfB7TAIAMHOQVpyZf8ZwayvMQ0Dnl5L
N9c+ttuSDTlrIApj20Hz8Ezp1Z+u91euwhGizXq61F5KBmD2J1CmjNXIsanLlRn5
DXebrls7KRLwqRAPf6HciIaU8G0d9ktP1Z3cHDRgLbc43cEEJHHi5WuMREtENTF2
RUkQwh8m7PTlzFnyIGVnamTkpF9AC2xK4XSlrdVSn+tEWFMVXPWo8EIvh1vJRwZ3
CKCF/aLyVC/DD2LAi9IWHIx4MQ4x9LoQFzBiOzkhhv63JmL0hd8E6GNei6VQS/yK
rQ+Td8YEwOVttpXF62CiNarYzKmOoMhJ3oaKt922V6uoxIXh3/Dh4xSXt/ZDxV0=
=q2uo
-----END PGP SIGNATURE-----

--------------020907050005030601080603
Content-Type: text/plain;
 name="kib-vfs_mount.c.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="kib-vfs_mount.c.diff"

Index: sys/kern/vfs_mount.c
===================================================================
--- sys/kern/vfs_mount.c	(revision 224652)
+++ sys/kern/vfs_mount.c	(working copy)
@@ -746,13 +746,15 @@ vfs_domount_first(
 	struct thread *td,		/* Calling thread. */
 	struct vfsconf *vfsp,		/* File system type. */
 	struct vnode *vp,		/* Vnode to be covered. */
+	char *ufspath,
 	int fsflags,			/* Flags common to all filesystems. */
 	struct vfsoptlist **optlist	/* Options local to the filesystem. */
 	)
 {
 	struct vattr va;
+	struct nameidata nd;
 	struct mount *mp;
-	struct vnode *newdp;
+	struct vnode *newdp, *vp1;
 	char *fspath, *fbuf;
 	int error;
 
@@ -761,18 +763,47 @@ vfs_domount_first(
 	KASSERT((fsflags & MNT_UPDATE) == 0, ("MNT_UPDATE shouldn't be here"));
 
 	/* Construct global filesystem path from vp. */
+	VOP_UNLOCK(vp, 0);
 	error = vn_fullpath_global(td, vp, &fspath, &fbuf);
 	if (error != 0) {
-		vput(vp);
+		vrele(vp);
 		return (error);
 	}
 	if (strlen(fspath) >= MNAMELEN) {
-		vput(vp);
+		vrele(vp);
 		free(fbuf, M_TEMP);
 		return (ENAMETOOLONG);
 	}
+	if ((vp->v_iflag & VI_DOOMED) != 0) {
+		vrele(vp);
+		free(fbuf, M_TEMP);
+		return (EBADF);
+	}
 
 	/*
+	 * Re-lookup the vnode by path. As a side effect, the vnode is
+	 * relocked.  If vnode was renamed, return ENOENT.
+	 */
+	NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1,
+	    UIO_SYSSPACE, ufspath, td);
+	error = namei(&nd);
+	if (error != 0) {
+		vrele(vp);
+		free(fbuf, M_TEMP);
+		return (error);
+	}
+	if (NDHASGIANT(&nd))
+		mtx_unlock(&Giant);
+	NDFREE(&nd, NDF_ONLY_PNBUF);
+	vp1 = nd.ni_vp;
+	vrele(vp);
+	if (vp1 != vp) {
+		vput(vp1);
+		free(fbuf, M_TEMP);
+		return (ENOENT);
+	}
+
+	/*
 	 * If the user is not root, ensure that they own the directory
 	 * onto which we are attempting to mount.
 	 */
@@ -1084,14 +1115,11 @@ vfs_domount(
 	NDFREE(&nd, NDF_ONLY_PNBUF);
 	vp = nd.ni_vp;
 	if ((fsflags & MNT_UPDATE) == 0)
-		error = vfs_domount_first(td, vfsp, vp, fsflags, optlist);
+		error = vfs_domount_first(td, vfsp, vp, fspath, fsflags, optlist);
 	else
 		error = vfs_domount_update(td, vp, fsflags, optlist);
 	mtx_unlock(&Giant);
 
-	ASSERT_VI_UNLOCKED(vp, __func__);
-	ASSERT_VOP_UNLOCKED(vp, __func__);
-
 	return (error);
 }
 

--------------020907050005030601080603--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4E3B2202.30205>