Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Oct 2019 10:33:21 +0000 (UTC)
From:      Toomas Soome <tsoome@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r354114 - stable/12/stand/libsa/zfs
Message-ID:  <201910261033.x9QAXLNC006955@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tsoome
Date: Sat Oct 26 10:33:21 2019
New Revision: 354114
URL: https://svnweb.freebsd.org/changeset/base/354114

Log:
  MFC r353757:
  loader: zfs_fmtdev can crash when pool discovery did fail and we have no spa
  
  When zfs probe did fail and no spa was created, but zfs_fmtdev() is called,
  we will crash while dereferencing spa (NULL pointer dereference).

Modified:
  stable/12/stand/libsa/zfs/zfs.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/stand/libsa/zfs/zfs.c
==============================================================================
--- stable/12/stand/libsa/zfs/zfs.c	Sat Oct 26 08:37:28 2019	(r354113)
+++ stable/12/stand/libsa/zfs/zfs.c	Sat Oct 26 10:33:21 2019	(r354114)
@@ -769,11 +769,16 @@ zfs_fmtdev(void *vdev)
 	if (dev->dd.d_dev->dv_type != DEVT_ZFS)
 		return (buf);
 
-	if (dev->pool_guid == 0) {
-		spa = STAILQ_FIRST(&zfs_pools);
+	/* Do we have any pools? */
+	spa = STAILQ_FIRST(&zfs_pools);
+	if (spa == NULL)
+		return (buf);
+
+	if (dev->pool_guid == 0)
 		dev->pool_guid = spa->spa_guid;
-	} else
+	else
 		spa = spa_find_by_guid(dev->pool_guid);
+
 	if (spa == NULL) {
 		printf("ZFS: can't find pool by guid\n");
 		return (buf);



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