Bug 247278 - partprobe attempts to repair GPT signatures without confirmation
partprobe attempts to repair GPT signatures without confirmation
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: parted (Show other bugs)
4.5
All Linux
high Severity high
: ---
: ---
Assigned To: David Cantrell
Alexander Todorov
:
Depends On:
Blocks: 246627
  Show dependency treegraph
 
Reported: 2007-07-06 12:29 EDT by Bryn M. Reeves
Modified: 2010-10-22 12:09 EDT (History)
3 users (show)

See Also:
Fixed In Version: RHBA-2008-0698
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-07-24 15:49:44 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
patch to reject gpt on-disk modifications from partprobe (611 bytes, patch)
2007-07-06 14:57 EDT, Bryn M. Reeves
no flags Details | Diff

  None (edit)
Description Bryn M. Reeves 2007-07-06 12:29:48 EDT
Description of problem:
The partprobe tool on finding a backup GPT signature on a block device that
lacks a correct primary signature/protective MBR will attempt to restore the GPT
disk label without confirmation from the user.

If the device previously contained a GPT partition table but has since been
re-used for other data without being completely wiped this risks corruption of
the device contents.

Version-Release number of selected component (if applicable):
parted-1.6.19-4.EL

How reproducible:
100%

Steps to Reproduce:
[ Example - there are lots of ways to trigger this ]
1. Set up a GPT label with a couple of partitions, e.g.:
       Disk /dev/sdc: 65.5MB
       Sector size (logical/physical): 512B/512B
       Partition Table: gpt
       
       Number  Start   End     Size     File system  Name     Flags
        1      17.4kB  20.0MB  20.0MB                primary       
        2      20.0MB  30.0MB  10000kB               primary       

2. Overwrite the device with something else, e.g.:
# mke2fs /dev/sdc 2000
mke2fs 1.39 (29-May-2006)
/dev/sdc is entire device, not just one partition!
Proceed anyway? (y,n) y 
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
256 inodes, 2000 blocks
100 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=2097152
1 block group
8192 blocks per group, 8192 fragments per group
256 inodes per group

Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

3. Run partprobe on the device:
# partprobe /dev/sdc
  
Actual results:
Warning: /dev/sdc contains GPT signatures, indicating that it has a GPT table. 
However, it does not have a valid fake msdos partition table, as it should. 
Perhaps it was corrupted - possibly by a program that doesn't understand GPT
partition tables.  Or perhaps you deleted the GPT table, and are now using an
msdos partition table.  Is this a GPT partition table?
Error: The primary GPT table is corrupt, but the backup appears ok, so that will
be used.

Note that none of these prompts are interactive - partprobe does not accept user
input before carrying on and correcting the GPT table.

# file -s /dev/sdc
/dev/sdc: x86 boot sector, extended partition table

# e2fsck -fn /dev/sdc
e2fsck 1.35 (28-Feb-2004)
Couldn't find ext2 superblock, trying backup blocks...
Resize inode not valid.  Recreate? no

Pass 1: Checking inodes, blocks, and sizes
Inode 7 has illegal block(s).  Clear? no

Illegal block #11021 (33619980) in inode 7.  IGNORED.
Illegal block #11024 (33685516) in inode 7.  IGNORED.
Illegal block #11027 (34210792) in inode 7.  IGNORED.
Illegal block #11028 (1953722220) in inode 7.  IGNORED.
Illegal block #11029 (1970234923) in inode 7.  IGNORED.
Illegal block #11277 (33619980) in inode 7.  IGNORED.
Illegal block #11280 (33686516) in inode 7.  IGNORED.
Inode 7, i_blocks is 2492, should be 2108.  Fix? no

Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/sdc: ********** WARNING: Filesystem still has errors **********

/dev/sdc: 11/16000 files (9.1% non-contiguous), 3286/63968 blocks


Expected results:
Either partprobe waits for user input (as the prompts suggest it will) before
modifying the disk contents, or aborts with a message instructing the user to
resolve the partitioning problem first and try again.

Additional info:
This is in practise fairly easy to run into since most disk labeling / file
system / data base schemes store their superblock or equivalent at the front of
the disk.

This was seen in production with Oracle ASM volumes where the ASM label is
written at the start of the disk. In this case, the devices had been
automatically partitioned as GPT at installation time due to architecture (ia64).
Comment 1 Bryn M. Reeves 2007-07-06 13:40:27 EDT
Confirmed that this does not occur with parted-1.8.7
Comment 2 Bryn M. Reeves 2007-07-06 14:57:33 EDT
Created attachment 158691 [details]
patch to reject gpt on-disk modifications from partprobe

Very rough first-cut attempt at preventing partprobe automatically fixing
corrupted GPT signatures.

FIXME:
- doesn't print exception text
- doesn't notify user of the problem

Still not sure why this is fixed upstream, but the changes to GPT handling
being worked on atm seem the most likely - this might still be the better fix
if the changes are not too invasive for RHEL4
Comment 3 RHEL Product and Program Management 2007-11-28 23:17:51 EST
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.
Comment 5 David Cantrell 2008-03-17 22:33:46 EDT
Backporting GPT changes from RHEL-5 is far too invasive for this code base.  Modified Bryn's patch a bit to 
display the exception message and then tell the user nothing happened.  Probably reasonable for RHEL-4.

Will be fixed in parted-1.6.19-20.EL.
Comment 7 Alexander Todorov 2008-06-06 09:34:44 EDT
Output now is:

# partprobe  -s  /dev/sdb
Warning: /dev/sdb contains GPT signatures, indicating that it has a GPT table. 
However, it does not have a valid fake msdos partition table, as it should. 
Perhaps it was corrupted - possibly by a program that doesn't understand GPT
partition tables.  Or perhaps you deleted the GPT table, and are now using an
msdos partition table.  Is this a GPT partition table?

No changes made to disk, exiting partprobe.


Comment 10 errata-xmlrpc 2008-07-24 15:49:44 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2008-0698.html

Note You need to log in before you can comment on or make changes to this bug.