Bug 148688

Summary: [geom][panic] panic when committing undone partitioning with BSD slice
Product: Base System Reporter: Rebecca Cran <bcran>
Component: kernAssignee: Andrey V. Elsukov <ae>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Rebecca Cran freebsd_committer freebsd_triage 2010-07-16 19:20:06 UTC
When attemting to commit a partition table which has been created with a BSD 
slice and then undone, the kernel panics in g_part_ctl_commit.

How-To-Repeat: gpart create -s mbr -f x da0
gpart add -t freebsd -f x da0
gpart create -s bsd -f x da0s1
gpart undo da0
gpart commit da0
Comment 1 Rebecca Cran freebsd_committer freebsd_triage 2010-07-16 20:22:10 UTC
"gpart show" also segfaults after running the "undo" because it appears not 
all fields were cleared. The crash occurs in geom/class/part/geom_part.c:530 
when NULL is passed to strtoimax; 'gp' contains: 

{ lg_id = 0xffffff001d441200, lg_class = 0x801045460, 
lg_name = 0x8010190b8 "da0", lg_rank = 2, lg_geom = {le_next = 0x801046bf0,
le_prev = 0x801046d50}, lg_consumer = {lh_first = 0x801046ce0},
lg_provider = {lh_first = 0x801032380}, lg_config = {lh_first = 0x0}}
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2010-07-16 20:29:25 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-geom

Over to maintainer(s).
Comment 3 Andrey V. Elsukov freebsd_committer freebsd_triage 2010-07-17 07:37:23 UTC
Responsible Changed
From-To: freebsd-geom->ae

Take.
Comment 4 Andrey V. Elsukov freebsd_committer freebsd_triage 2010-07-19 06:29:02 UTC
This is a multi-part message in MIME format.
Comment 5 Andrey V. Elsukov freebsd_committer freebsd_triage 2010-07-19 15:55:30 UTC
State Changed
From-To: open->feedback

feedback requested.
Comment 6 brucec 2010-07-21 14:13:35 UTC
On Mon, Jul 19, 2010 at 09:29:02AM +0400, Andrey V. Elsukov wrote:

> can you test following patch?

Thanks, the patch fixes the problem.

-- 
Bruce Cran
Comment 7 dfilter service freebsd_committer freebsd_triage 2010-08-02 11:26:28 UTC
Author: ae
Date: Mon Aug  2 10:26:15 2010
New Revision: 210746
URL: http://svn.freebsd.org/changeset/base/210746

Log:
  Release access for consumers that are opened, but will be destroyed
  indirectly by orphan method.
  
  PR:		148688
  Silence from:	marcel
  Approved by:	mav (mentor)
  MFC after: 	2 weeks

Modified:
  head/sys/geom/part/g_part.c

Modified: head/sys/geom/part/g_part.c
==============================================================================
--- head/sys/geom/part/g_part.c	Mon Aug  2 09:13:09 2010	(r210745)
+++ head/sys/geom/part/g_part.c	Mon Aug  2 10:26:15 2010	(r210746)
@@ -1739,6 +1739,7 @@ static void
 g_part_orphan(struct g_consumer *cp)
 {
 	struct g_provider *pp;
+	struct g_part_table *table;
 
 	pp = cp->provider;
 	KASSERT(pp != NULL, (__func__));
@@ -1746,6 +1747,9 @@ g_part_orphan(struct g_consumer *cp)
 	g_topology_assert();
 
 	KASSERT(pp->error != 0, (__func__));
+	table = cp->geom->softc;
+	if (table->gpt_opened)
+		g_access(cp, -1, -1, -1);
 	g_part_wither(cp->geom, pp->error);
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 8 Andrey V. Elsukov freebsd_committer freebsd_triage 2010-08-02 11:31:40 UTC
State Changed
From-To: feedback->patched

Patched in head/.
Comment 9 dfilter service freebsd_committer freebsd_triage 2010-08-16 09:48:50 UTC
Author: ae
Date: Mon Aug 16 08:48:39 2010
New Revision: 211390
URL: http://svn.freebsd.org/changeset/base/211390

Log:
  MFC r210746:
    Release access for consumers that are opened, but will be destroyed
    indirectly by orphan method.
  
    PR:		148688
  
  MFC r210792:
    Check that table is not NULL before access, it can be NULL
    for some cases.
  
  Approved by: kib (mentor)

Modified:
  stable/8/sys/geom/part/g_part.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cam/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/e1000/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/geom/part/g_part.c
==============================================================================
--- stable/8/sys/geom/part/g_part.c	Mon Aug 16 04:22:29 2010	(r211389)
+++ stable/8/sys/geom/part/g_part.c	Mon Aug 16 08:48:39 2010	(r211390)
@@ -1738,6 +1738,7 @@ static void
 g_part_orphan(struct g_consumer *cp)
 {
 	struct g_provider *pp;
+	struct g_part_table *table;
 
 	pp = cp->provider;
 	KASSERT(pp != NULL, (__func__));
@@ -1745,6 +1746,9 @@ g_part_orphan(struct g_consumer *cp)
 	g_topology_assert();
 
 	KASSERT(pp->error != 0, (__func__));
+	table = cp->geom->softc;
+	if (table != NULL && table->gpt_opened)
+		g_access(cp, -1, -1, -1);
 	g_part_wither(cp->geom, pp->error);
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 10 Andrey V. Elsukov freebsd_committer freebsd_triage 2010-08-16 09:52:54 UTC
State Changed
From-To: patched->closed

Merged to stable/8.