NetBSD Problem Report #53668

From riz@cassava.tastylime.net  Sun Oct 14 19:25:18 2018
Return-Path: <riz@cassava.tastylime.net>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 9DD017A262
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 14 Oct 2018 19:25:18 +0000 (UTC)
Message-Id: <20181014192517.1A865416446@cassava.tastylime.net>
Date: Sun, 14 Oct 2018 12:25:17 -0700 (PDT)
From: riz@NetBSD.org
Reply-To: riz@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: gpt(8) remove -L does exactly the wrong thing
X-Send-Pr-Version: 3.95

>Number:         53668
>Category:       bin
>Synopsis:       gpt(8) remove -L removes all partitions EXCEPT the right one
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 14 19:30:01 +0000 2018
>Last-Modified:  Mon Oct 15 08:05:00 +0000 2018
>Originator:     riz@NetBSD.org
>Release:        NetBSD 8.0
>Organization:

>Environment:
System: NetBSD cassava.tastylime.net 8.0 NetBSD 8.0 (GENERIC) #0: Tue Jul 17 14:59:51 UTC 2018 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:

On a production NetBSD 8.0 box, I wanted to remove a gpt partition with a
particular label; I used 
gpt remove -L partition-to-remove wd0

...and it removed ALL PARTITIONS *except* the labeled one.

Here's me duplicating it with a vnd on a different NetBSD 8.0 box:

cassava:riz  ~> sudo gpt show -l vnd0
    start     size  index  contents
        0        1         PMBR
        1        1         Pri GPT header
        2       32         Pri GPT table
       34    10000      1  GPT part - first_part
    10034    10000      2  GPT part - second_part
    20034    10000      3  GPT part - third_part
    30034    10000      4  GPT part - fourth_part
    40034   983933         Unused
  1023967       32         Sec GPT table
  1023999        1         Sec GPT header
cassava:riz  ~> sudo gpt remove -L third_part vnd0
/dev/rvnd0d: Partition 1 removed
/dev/rvnd0d: Partition 2 removed
/dev/rvnd0d: Partition 4 removed
cassava:riz  ~> sudo gpt show -l vnd0
    start     size  index  contents
        0        1         PMBR
        1        1         Pri GPT header
        2       32         Pri GPT table
       34    20000         Unused
    20034    10000      3  GPT part - third_part
    30034   993933         Unused
  1023967       32         Sec GPT table
  1023999        1         Sec GPT header
cassava:riz  ~>

Boy, was this annoying.  Luckily, on the production machine I had just shown
all the partitions, so I was able to recreate them, but this could have
royally screwed up my day.
>How-To-Repeat:
	- create a gpt-partitioned disk with multiple labeled partitions.
	- use "gpt remove -L partition-to-remove" <disk>
	- watch it remove all OTHER partitions.
>Fix:
	none given.

>Audit-Trail:
From: "Michael van Elst" <mlelstv@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53668 CVS commit: src/sbin/gpt
Date: Sun, 14 Oct 2018 20:10:49 +0000

 Module Name:	src
 Committed By:	mlelstv
 Date:		Sun Oct 14 20:10:49 UTC 2018

 Modified Files:
 	src/sbin/gpt: gpt.c

 Log Message:
 When changing entries skip those that do not match the -L option.
 Should fix PR 53668.


 To generate a diff of this commit:
 cvs rdiff -u -r1.75 -r1.76 src/sbin/gpt/gpt.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: mlelstv@serpens.de (Michael van Elst)
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/53668: gpt(8) remove -L does exactly the wrong thing
Date: Sun, 14 Oct 2018 20:12:39 -0000 (UTC)

 riz@NetBSD.org writes:

 >On a production NetBSD 8.0 box, I wanted to remove a gpt partition with a
 >particular label; I used 
 >gpt remove -L partition-to-remove wd0

 >...and it removed ALL PARTITIONS *except* the labeled one.

 The match condition was inverted after refactoring the code. I just
 committed the fix to -current. Please verify.

 -- 
 -- 
                                 Michael van Elst
 Internet: mlelstv@serpens.de
                                 "A potential Snark may lurk in every tree."

From: Jeff Rizzo <riz@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: PR/53668 CVS commit: src/sbin/gpt
Date: Sun, 14 Oct 2018 15:47:51 -0700

 Confirmed; this fixes the problem.  Thanks!

From: "Stephen Borrill" <sborrill@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53668 CVS commit: [netbsd-7] src/sbin/gpt
Date: Mon, 15 Oct 2018 07:55:50 +0000

 Module Name:	src
 Committed By:	sborrill
 Date:		Mon Oct 15 07:55:50 UTC 2018

 Modified Files:
 	src/sbin/gpt [netbsd-7]: gpt.c

 Log Message:
 Pull up the following revisions(s) (requested by mlelstv in ticket #1643):
 	sbin/gpt/gpt.c:	revision 1.76

 When changing entries skip those that do not match the -L option.
 Should fix PR 53668.


 To generate a diff of this commit:
 cvs rdiff -u -r1.28.2.2 -r1.28.2.3 src/sbin/gpt/gpt.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Stephen Borrill" <sborrill@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53668 CVS commit: [netbsd-8] src/sbin/gpt
Date: Mon, 15 Oct 2018 08:04:04 +0000

 Module Name:	src
 Committed By:	sborrill
 Date:		Mon Oct 15 08:04:04 UTC 2018

 Modified Files:
 	src/sbin/gpt [netbsd-8]: gpt.c

 Log Message:
 Pull up the following revisions(s) (requested by mlelstv in ticket #1063):
 	sbin/gpt/gpt.c:	revision 1.76

 When changing entries, skip those that do not match the -L option.
 Should fix PR 53668.


 To generate a diff of this commit:
 cvs rdiff -u -r1.70.4.2 -r1.70.4.3 src/sbin/gpt/gpt.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.