From owner-svn-src-all@freebsd.org Tue Feb 13 17:40:09 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D4C99F142E8; Tue, 13 Feb 2018 17:40:09 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8850085D49; Tue, 13 Feb 2018 17:40:09 +0000 (UTC) (envelope-from jhibbits@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 832CC23EA9; Tue, 13 Feb 2018 17:40:09 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1DHe9wN097369; Tue, 13 Feb 2018 17:40:09 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1DHe9IN097368; Tue, 13 Feb 2018 17:40:09 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201802131740.w1DHe9IN097368@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Tue, 13 Feb 2018 17:40:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329225 - head/sys/geom/part X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/geom/part X-SVN-Commit-Revision: 329225 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.25 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: Tue, 13 Feb 2018 17:40:10 -0000 Author: jhibbits Date: Tue Feb 13 17:40:09 2018 New Revision: 329225 URL: https://svnweb.freebsd.org/changeset/base/329225 Log: Narrow a race, and fix a leak, in g_part_wither A race in g_part_wither() can lead to I/O being performed with a freed GEOM when the device disappears. Close the race as best as we can for now, following the code patterns from g_part_ctl_destroy() and g_part_ctl_undo(). This also fixes a leak, as g_wither_geom() does not wither providers, it only orphans them, so the partition entries would never get destroyed in g_wither_washer(). Note, this is not a complete fix, it can still race with g_part_start(), the race has merely been narrowed. Reviewed by: markj Sponsored by: Dell EMC Isilon Modified: head/sys/geom/part/g_part.c Modified: head/sys/geom/part/g_part.c ============================================================================== --- head/sys/geom/part/g_part.c Tue Feb 13 17:38:08 2018 (r329224) +++ head/sys/geom/part/g_part.c Tue Feb 13 17:40:09 2018 (r329225) @@ -1541,18 +1541,21 @@ g_part_wither(struct g_geom *gp, int error) { struct g_part_entry *entry; struct g_part_table *table; + struct g_provider *pp; table = gp->softc; if (table != NULL) { - G_PART_DESTROY(table, NULL); + gp->softc = NULL; while ((entry = LIST_FIRST(&table->gpt_entry)) != NULL) { LIST_REMOVE(entry, gpe_entry); + pp = entry->gpe_pp; + entry->gpe_pp->private = NULL; + entry->gpe_pp = NULL; + g_wither_provider(pp, error); g_free(entry); } - if (gp->softc != NULL) { - kobj_delete((kobj_t)gp->softc, M_GEOM); - gp->softc = NULL; - } + G_PART_DESTROY(table, NULL); + kobj_delete((kobj_t)table, M_GEOM); } g_wither_geom(gp, error); }