Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Jan 2014 22:14:12 +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: r260339 - in stable/10: cddl/contrib/opensolaris/lib/libzfs/common sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <201401052214.s05MECxh003510@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sun Jan  5 22:14:12 2014
New Revision: 260339
URL: http://svnweb.freebsd.org/changeset/base/260339

Log:
  MFC r259168:
  Don't even try to read vdev labels from devices smaller then SPA_MINDEVSIZE
  (64MB).  Even if we would find one somehow, ZFS kernel code rejects such
  devices.  It is funny to look on attempts to read 4 256K vdev labels from
  1.44MB floppy, though it is not very practical and quite slow.

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

Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
==============================================================================
--- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c	Sun Jan  5 22:12:45 2014	(r260338)
+++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c	Sun Jan  5 22:14:12 2014	(r260339)
@@ -995,10 +995,10 @@ nozpool_all_slices(avl_tree_t *r, const 
 #endif	/* sun */
 }
 
+#ifdef sun
 static void
 check_slices(avl_tree_t *r, int fd, const char *sname)
 {
-#ifdef sun
 	struct extvtoc vtoc;
 	struct dk_gpt *gpt;
 	char diskname[MAXNAMELEN];
@@ -1028,8 +1028,8 @@ check_slices(avl_tree_t *r, int fd, cons
 			check_one_slice(r, diskname, i, 0, 1);
 		efi_free(gpt);
 	}
-#endif	/* sun */
 }
+#endif	/* sun */
 
 static void
 zpool_open_func(void *arg)
@@ -1059,6 +1059,7 @@ zpool_open_func(void *arg)
 		return;
 	}
 	/* this file is too small to hold a zpool */
+#ifdef sun
 	if (S_ISREG(statbuf.st_mode) &&
 	    statbuf.st_size < SPA_MINDEVSIZE) {
 		(void) close(fd);
@@ -1070,6 +1071,12 @@ zpool_open_func(void *arg)
 		 */
 		check_slices(rn->rn_avl, fd, rn->rn_name);
 	}
+#else	/* !sun */
+	if (statbuf.st_size < SPA_MINDEVSIZE) {
+		(void) close(fd);
+		return;
+	}
+#endif	/* sun */
 
 	if ((zpool_read_label(fd, &config)) != 0) {
 		(void) close(fd);

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
==============================================================================
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c	Sun Jan  5 22:12:45 2014	(r260338)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c	Sun Jan  5 22:14:12 2014	(r260339)
@@ -370,10 +370,16 @@ vdev_geom_attach_taster(struct g_consume
 
 	if (pp->flags & G_PF_WITHER)
 		return (EINVAL);
-	if (pp->sectorsize > VDEV_PAD_SIZE || !ISP2(pp->sectorsize))
-		return (EINVAL);
 	g_attach(cp, pp);
 	error = g_access(cp, 1, 0, 0);
+	if (error == 0) {
+		if (pp->sectorsize > VDEV_PAD_SIZE || !ISP2(pp->sectorsize))
+			error = EINVAL;
+		else if (pp->mediasize < SPA_MINDEVSIZE)
+			error = EINVAL;
+		if (error != 0)
+			g_access(cp, -1, 0, 0);
+	}
 	if (error != 0)
 		g_detach(cp);
 	return (error);



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