From bruce@cran.org.uk  Fri Jul 16 18:11:39 2010
Return-Path: <bruce@cran.org.uk>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 863271065673
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 16 Jul 2010 18:11:39 +0000 (UTC)
	(envelope-from bruce@cran.org.uk)
Received: from mtaout01-winn.ispmail.ntl.com (mtaout01-winn.ispmail.ntl.com [81.103.221.47])
	by mx1.freebsd.org (Postfix) with ESMTP id E75008FC1A
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 16 Jul 2010 18:11:38 +0000 (UTC)
Received: from know-smtpout-4.server.virginmedia.net ([62.254.123.2])
          by mtaout01-winn.ispmail.ntl.com
          (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP
          id <20100716181137.YZVU3266.mtaout01-winn.ispmail.ntl.com@know-smtpout-4.server.virginmedia.net>
          for <FreeBSD-gnats-submit@freebsd.org>;
          Fri, 16 Jul 2010 19:11:37 +0100
Received: from [86.31.3.93] (helo=bsdbook.nessbank)
	by know-smtpout-4.server.virginmedia.net with smtp (Exim 4.63)
	(envelope-from <bruce@cran.org.uk>)
	id 1OZpNk-0002vi-UR
	for FreeBSD-gnats-submit@freebsd.org; Fri, 16 Jul 2010 19:11:33 +0100
Received: by bsdbook.nessbank (sSMTP sendmail emulation); Fri, 16 Jul 2010 19:11:47 +0100
Message-Id: <20100716181137.YZVU3266.mtaout01-winn.ispmail.ntl.com@know-smtpout-4.server.virginmedia.net>
Date: Fri, 16 Jul 2010 19:11:47 +0100
From: "Bruce Cran" <bruce@cran.org.uk>
Reply-To: Bruce Cran <bruce@cran.org.uk>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [geom][panic] panic when committing undone partitioning with BSD slice
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         148688
>Category:       kern
>Synopsis:       [geom][panic] panic when committing undone partitioning with BSD slice
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    ae
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 16 18:20:06 UTC 2010
>Closed-Date:    Mon Aug 16 08:53:25 UTC 2010
>Last-Modified:  Mon Aug 16 08:53:25 UTC 2010
>Originator:     Bruce Cran
>Release:        FreeBSD 9.0-HEAD-20100715-JPSNAP amd64
>Organization:
>Environment:
System: FreeBSD bsdbook.nessbank 9.0-HEAD-20100715-JPSNAP FreeBSD 9.0-HEAD-20100715-JPSNAP #0: Thu Jul 15 06:37:19 UTC 2010 root@build-amd64-fbsd.allbsd.org:/usr/obj/usr/src/sys/GENERIC amd64


	
>Description:
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
>Fix:

	


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-geom 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Fri Jul 16 19:29:25 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=148688 

From: Bruce Cran <bruce@cran.org.uk>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: kern/148688: [geom][panic] panic when committing undone partitioning with BSD slice
Date: Fri, 16 Jul 2010 19:22:10 +0000

 "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}}
  
Responsible-Changed-From-To: freebsd-geom->ae 
Responsible-Changed-By: ae 
Responsible-Changed-When: Sat Jul 17 06:37:23 UTC 2010 
Responsible-Changed-Why:  
Take. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=148688 

From: "Andrey V. Elsukov" <ae@freebsd.org>
To: bug-followup@FreeBSD.org, bruce@cran.org.uk
Cc: Marcel Moolenaar <marcel@FreeBSD.org>
Subject: Re: kern/148688: [geom][panic] panic when committing undone partitioning
 with BSD slice
Date: Mon, 19 Jul 2010 09:29:02 +0400

 This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
 --------------enigCABA0541E4E7485D279DED5A
 Content-Type: multipart/mixed;
  boundary="------------080606060509010501020205"
 
 This is a multi-part message in MIME format.
 --------------080606060509010501020205
 Content-Type: text/plain; charset=KOI8-R
 Content-Transfer-Encoding: quoted-printable
 
 Hi, Bruce
 
 can you test following patch?
 
 --=20
 WBR, Andrey V. Elsukov
 
 --------------080606060509010501020205
 Content-Type: text/plain;
  name="g_part2.diff"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment;
  filename="g_part2.diff"
 
 Index: head/sys/geom/part/g_part.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 --- head/sys/geom/part/g_part.c	(revision 210228)
 +++ head/sys/geom/part/g_part.c	(working copy)
 @@ -1746,6 +1746,8 @@ g_part_orphan(struct g_consumer *cp)
  	g_topology_assert();
 =20
  	KASSERT(pp->error !=3D 0, (__func__));
 +	if (pp->ace > 0)
 +		g_access(cp, -1, -1, -1);
  	g_part_wither(cp->geom, pp->error);
  }
 =20
 
 --------------080606060509010501020205--
 
 --------------enigCABA0541E4E7485D279DED5A
 Content-Type: application/pgp-signature; name="signature.asc"
 Content-Description: OpenPGP digital signature
 Content-Disposition: attachment; filename="signature.asc"
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.10 (MingW32)
 
 iQEcBAEBAgAGBQJMQ+KiAAoJEAHF6gQQyKF6aYwH/28f2rbHxcLlvHMAm7+/9pca
 AtvdcriQQhD5YRYaB5cwMQTxeE7Fmdw9zUdRRQAquFq8Eo+ckWbQ/+bQsOZO7G0+
 EAfGT+E/VG087zzB1eq0XHEtQiEyJ1mFgEsCHj1fDuififpGzPB/h42jm3DMpb6u
 kpyKuKZnCmFJgkvPWcvgFrlk7BCBcWMfBRM8mJi4qeW2dwPFvIA2kr60ec0PGHDL
 0/znKwcpJWa4TEryClRKBLrML73KnEv2t4wX68eHgDRwIrXiDFE9+p6ybh21Ygvn
 rTppx9gEkNv25URA3Z4q2v5QIvwgXoudpH8mvh1vdOrSGP15P50ihG2xdXqGewU=
 =m2+Q
 -----END PGP SIGNATURE-----
 
 --------------enigCABA0541E4E7485D279DED5A--
State-Changed-From-To: open->feedback 
State-Changed-By: ae 
State-Changed-When: Mon Jul 19 14:55:30 UTC 2010 
State-Changed-Why:  
feedback requested. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=148688 

From: Bruce Cran <brucec@muon.cran.org.uk>
To: "Andrey V. Elsukov" <ae@freebsd.org>
Cc: bug-followup@FreeBSD.org, bruce@cran.org.uk,
	Marcel Moolenaar <marcel@FreeBSD.org>
Subject: Re: kern/148688: [geom][panic] panic when committing undone partitioning with BSD slice
Date: Wed, 21 Jul 2010 13:13:35 +0000

 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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/148688: commit references a PR
Date: Mon,  2 Aug 2010 10:26:28 +0000 (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"
 
State-Changed-From-To: feedback->patched 
State-Changed-By: ae 
State-Changed-When: Mon Aug 2 10:31:40 UTC 2010 
State-Changed-Why:  
Patched in head/. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=148688 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/148688: commit references a PR
Date: Mon, 16 Aug 2010 08:48:50 +0000 (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"
 
State-Changed-From-To: patched->closed 
State-Changed-By: ae 
State-Changed-When: Mon Aug 16 08:52:54 UTC 2010 
State-Changed-Why:  
Merged to stable/8. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=148688 
>Unformatted:
