[Parted-maintainers] Bug#401532: fixing EFI GPT table on expanded device results in segfault

Anders Henke anders at schlund.de
Mon Dec 4 11:25:00 CET 2006


Package: parted
Version: 1.7.1-2
Severity: important

I'm running Debian 3.1/AMD64 on Kernel 2.6.18.3 with a >2 TB 
fibrechannel-connected external RAID controller. The kernel
is a custom build and includes EFI-GPT and LBD-support.

---cut
sdb : very big device. try to use READ CAPACITY(16).
SCSI device sdb: 10741948416 512-byte hdwr sectors (5499878 MB)
sdb: Write Protect is off
sdb: Mode Sense: bf 00 10 08
SCSI device sdb: drive cache: write back w/ FUA
 sdb: sdb1
---cut

The single partition on that device is an EFI GPT partition at the
full device size with an XFS filesystem on it. The partition has been
created with GNU parted as well.

The RAID controller is an Overland Ultamusraid 5200, which in turn
seems to be an Ario Networks OEM'd device. The controller allows
array expansion, where newly added drives enable the administrator
to both add a new logical device (from Linux view: new disk device; 
from Controller view: some kind of "partition" on the same RAID set)
as well as expand currently existing logical devices (from Linux' point
of view, your devices do become bigger).

After expanding the RAID by another disk and extending the existing 
logical drive's capacity to the new maximum, the RAID controller simply
exports a new disk size under the same LUN, so 
"/sbin/blockdev --rereadpt /dev/sdb" makes Linux rescan the
new disk size:

---cut
sdb : very big device. try to use READ CAPACITY(16).
SCSI device sdb: 11716890624 512-byte hdwr sectors (5999048 MB)
sdb: Write Protect is off
sdb: Mode Sense: bf 00 10 08
SCSI device sdb: drive cache: write back w/ FUA
 sdb: sdb1
---cut

The new device is about 0.5 TB larger. EFI GPT contains a backup of the
partiton table at the end of the disk, obviously now that space has
become empty.

I think that similar situation (at least for parted) can also be 
reproduced via "standard" Linux LVM (lvcreate some logical volume, 
create a EFI-GPT-partition on it via parted, lvextend the logical volume,
re-run parted). I know that the partitioned LVM device is likely unusable
for you, but it should work for parted and reproduce this bug.

parted from sarge, 1.6.21-1:

---cut
anders1:~# parted /dev/sdb
GNU Parted 1.6.21 with HFS shrink patch 16
Copyright (C) 1998 - 2004 Free Software Foundation, Inc.
This program is free software, covered by the GNU General Public
License.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU General Public License for more
details.

Using /dev/sdb
(parted) p                                                                
Error: The backup GPT table is not at the end of the disk, as it should
be.
This might mean that another operating system believes the disk is
smaller.
Fix, by moving the backup to the end (and removing the old backup)?
Fix/Cancel? fix                                                           
Segmentation fault
anders1:~# dmesg
[...]
program parted is using a deprecated SCSI ioctl, please convert it to SG_IO
parted[20231]: segfault at 0000000000000000 rip 00002b09224c28f2 rsp 00007fff88c681b8 error 4
program parted is using a deprecated SCSI ioctl, please convert it to SG_IO
parted[20233]: segfault at 0000000000000000 rip 00002ad2333758f2 rsp 00007fff77db72f8 error 4
---cut

parted 1.7.1-2, backported to sarge:
---cut
anders1:~# parted /dev/sdb
GNU Parted 1.7.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                
Error: The backup GPT table is not at the end of the disk, as it should
be.
This might mean that another operating system believes the disk is
smaller.
Fix, by moving the backup to the end (and removing the old backup)?
Fix/Cancel? fix                                                           
                                                                          

You found a bug in GNU Parted! Here's what you have to do:

Don't panic! The bug has most likely not affected any of your data.
Help us to fix this bug by doing the following:

Check whether the bug has already been fixed by checking
the last version of GNU Parted that you can find at:

        http://ftp.gnu.org/gnu/parted/

Please check this version prior to bug reporting.

If this has not been fixed yet or if you don't know how to check,
please visit the GNU Parted website:

        http://www.gnu.org/software/parted

for further information.

Your report should contain the version of this release (1.7.1)
along with the error message below, the output of

        parted DEVICE unit co print unit s print

and additional information about your setup you consider important.

Assertion (n > 0) at ../../libparted/exception.c:112 in function
ped_log2()
failed.

Ignore/Cancel? c


You found a bug in GNU Parted! Here's what you have to do:

[...]
and additional information about your setup you consider important.

Error: SEGV_MAPERR (Address not mapped to object)Aborted
---cut

The command "parted DEVICE unit co print unit s print" refuses to work 
without a "fixed" GPT table; running "f" or "fix" triggers the same
issue over and over again.

I've taken 1.8.1 from the "experimental" section, compiled it 
on my own ("configure && make && ./parted/parted /dev/sdb"):

---cut
anders1:/usr/src/deb/parted-1.8.1~git1# ./parted/parted /dev/sdb
GNU Parted 1.8.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                
Error: The backup GPT table is not at the end of the disk, as it should be.
This might mean that another operating system believes the disk is smaller.
Fix, by moving the backup to the end (and removing the old backup)?
Fix/Cancel? c                                                             
(parted) unit co print unit s print
Error: The backup GPT table is not at the end of the disk, as it should be.
This might mean that another operating system believes the disk is smaller.
Fix, by moving the backup to the end (and removing the old backup)?
Fix/Cancel? f                                                             
Warning: Not all of the space available to /dev/sdb appears to be used, you can
fix the GPT to use all of the space (an extra 974942208 blocks) or continue with
the current setting? 
Fix/Ignore? f                                                             

Model: Overland ULTAMUSRAID5200 (scsi)
Disk /dev/sdb: 5999GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
 1      17.4kB  5500GB  5500GB  xfs          primary       
---cut

The "not all of the space available to ... appears to be used"-message
uses a wrong question, but at least fixing the EFI GPT table works.

After fixing the table using 1.8.1, the table works with 1.7.1 back again:
---cut
anders1:~# parted /dev/sdb 
GNU Parted 1.7.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                

Disk /dev/sdb: 5999GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
 1      17.4kB  5500GB  5500GB  xfs          primary       

---cut

... and correctly works within Linux (blockdev --rereadpt, 
mount, use filesystem).

So in short: parted 1.6.26 from Sarge segfaults when trying to fix the
misaligned GPT table, parted 1.7.1-2 from unstable throws an exception 
and calls its own error handler, parted 1.8.1 from git correctly fixes 
the misaligned GPT table (with a slightly wrong message).


Anders




More information about the Parted-maintainers mailing list