From owner-svn-src-all@freebsd.org Fri Oct 28 18:22:01 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 80E2BC24C31; Fri, 28 Oct 2016 18:22:01 +0000 (UTC) (envelope-from mav@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 mx1.freebsd.org (Postfix) with ESMTPS id 4F9CF779; Fri, 28 Oct 2016 18:22:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9SIM0jT067634; Fri, 28 Oct 2016 18:22:00 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9SIM0fr067633; Fri, 28 Oct 2016 18:22:00 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610281822.u9SIM0fr067633@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 28 Oct 2016 18:22:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r308059 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-10 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.23 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: Fri, 28 Oct 2016 18:22:01 -0000 Author: mav Date: Fri Oct 28 18:22:00 2016 New Revision: 308059 URL: https://svnweb.freebsd.org/changeset/base/308059 Log: MFC r298814 (by asomers): Fix a use-after-free when "zpool import" fails clear vd->vdev_tsd in vdev_geom_close_locked instead of vdev_geom_detach. In the latter function, it would fail to happen in certain circumstances where cp->private was unset. Ideally, the latter should never happen, but it can happen when vdev open fails, or where spares are involved. Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Directory Properties: stable/10/ (props changed) 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 Fri Oct 28 18:20:14 2016 (r308058) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Fri Oct 28 18:22:00 2016 (r308059) @@ -278,10 +278,6 @@ vdev_geom_detach(struct g_consumer *cp, cp->provider && cp->provider->name ? cp->provider->name : "NULL"); vd = cp->private; - if (vd != NULL) { - vd->vdev_tsd = NULL; - vd->vdev_delayed_close = B_FALSE; - } cp->private = NULL; gp = cp->geom; @@ -313,6 +309,8 @@ vdev_geom_close_locked(vdev_t *vd) g_topology_assert(); cp = vd->vdev_tsd; + vd->vdev_tsd = NULL; + vd->vdev_delayed_close = B_FALSE; if (cp == NULL) return;