[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grub mishandles corrupt/missing primary GPT

From: Vladimir 'φ-coder/phcoder' Serbinenko
Subject: Re: grub mishandles corrupt/missing primary GPT
Date: Thu, 24 Oct 2013 03:49:59 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131005 Icedove/17.0.9

On 24.10.2013 03:38, Chris Murphy wrote:
> Gist is, starting with a disk with valid PMBR, primary GPT, and backup
> GPT, if I zero LBA 2, I can no longer boot from the disk. I get a grub
> rescue prompt.
> Instead, if I merely corrupt a portion of the first partitiontypeguid to
> mimic corruption, I can still boot, whereas this primary GPT fails
> checksums with both gdisk and parted. 
> This tells me that GRUB isn't checking for the validity of the primary
> GPT. And GRUB doesn't ever use the backup GPT.
> Expected behavior is GRUB should check if the MBR is a PMBR (1st and
> only entry is type 0xEE)
There are so called "hybrid" disks which we have to treat as GPT
> and if not then consider the disk MBR. If it is
> PMBR, check validity of the primary GPT header+table, if valid use it.
> If invalid, check validity of backup GPT header+table, if valid use it.
> If invalid, fail.
partmap module is size-critical and CRC32 verification is pretty big.
There are 3 problems with backup header:
1) Backup header would be preserved even when primary is deliberately
reformatted and if we use it then we'll use it even on disks where we
should use newly-created MBR
2) The disk size isn't always known (loopback over network device,
ieee1275 disks and CD-ROMs, possibly others)
3) There are some weird scenarios with USB enclosures "forgetting" last
disk sectors which leads to partition having two different back-headers.
Consider following scenario:
One formats with enclosure, then puts disk natively and moves backup
headers to real end of disk and later modifies partition table. Then
puts disk in enclosure again and then backup has older table.

Do you have ways to handle this?
Why primary would be corrupted in first place?
> Chris Murphy
> _______________________________________________
> Grub-devel mailing list
> address@hidden

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]