Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Mar 2016 20:27:52 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r297082 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <201603202027.u2KKRqEh061971@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sun Mar 20 20:27:52 2016
New Revision: 297082
URL: https://svnweb.freebsd.org/changeset/base/297082

Log:
  MFC r272359 (by will):
  zfsvfs_create(): Refuse to mount datasets whose names are too long.
  
  This is checked for in the zfs_snapshot_004_neg STF/ATF test (currently
  still in projects/zfsd rather than head).
  
  sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c:
  - zfsvfs_create(): Check whether the objset name fits into
    statfs.f_mntfromname, and return ENAMETOOLONG if not.  Although
    the filesystem can be unmounted via the umount(8) command, any
    interface that relies on iterating on statfs (e.g. libzfs) will
    fail to find the filesystem by its objset name, and thus assume
    it's not mounted.  This causes "zfs unmount", "zfs destroy",
    etc. to fail on these filesystems, whether or not -f is passed.
  
  MFSpectraBSD:   974872 on 2013/08/09

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
==============================================================================
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c	Sun Mar 20 20:25:36 2016	(r297081)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c	Sun Mar 20 20:27:52 2016	(r297082)
@@ -855,6 +855,17 @@ zfsvfs_create(const char *osname, zfsvfs
 	int i, error;
 	uint64_t sa_obj;
 
+	/*
+	 * XXX: Fix struct statfs so this isn't necessary!
+	 *
+	 * The 'osname' is used as the filesystem's special node, which means
+	 * it must fit in statfs.f_mntfromname, or else it can't be
+	 * enumerated, so libzfs_mnttab_find() returns NULL, which causes
+	 * 'zfs unmount' to think it's not mounted when it is.
+	 */
+	if (strlen(osname) >= MNAMELEN)
+		return (SET_ERROR(ENAMETOOLONG));
+
 	zfsvfs = kmem_zalloc(sizeof (zfsvfs_t), KM_SLEEP);
 
 	/*



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