From owner-svn-src-all@freebsd.org Sat Oct 26 10:33:22 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3633716A92A; Sat, 26 Oct 2019 10:33:22 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 470cl60hDNz41Cr; Sat, 26 Oct 2019 10:33:22 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EEE0A6A24; Sat, 26 Oct 2019 10:33:21 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9QAXLAW006956; Sat, 26 Oct 2019 10:33:21 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9QAXLNC006955; Sat, 26 Oct 2019 10:33:21 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201910261033.x9QAXLNC006955@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Sat, 26 Oct 2019 10:33:21 +0000 (UTC) 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 X-SVN-Group: stable-12 X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: stable/12/stand/libsa/zfs X-SVN-Commit-Revision: 354114 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Oct 2019 10:33:22 -0000 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);