Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

partitions/efi: loosen check fot pmbr size in lba

Matt found that commit 27a7c642174e ("partitions/efi: account for pmbr
size in lba") caused his GPT formatted eMMC device not to boot. The
reason is that this commit enforced Linux to always check the lesser of
the whole disk or 2Tib for the pMBR size in LBA. While most disk
partitioning tools out there create a pMBR with these characteristics,
Microsoft does not, as it always sets the entry to the maximum 32-bit
limitation - even though a drive may be smaller than that[1].

Loosen this check and only verify that the size is either the whole disk
or 0xFFFFFFFF. No tool in its right mind would set it to any value
other than these.

[1] http://thestarman.pcministry.com/asm/mbr/GPT.htm#GPTPT

Reported-and-tested-by: Matt Porter <matt.porter@linaro.org>
Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Davidlohr Bueso and committed by
Linus Torvalds
6b02fa59 3711d86a

+6 -2
+6 -2
block/partitions/efi.c
··· 186 186 */ 187 187 static int is_pmbr_valid(legacy_mbr *mbr, sector_t total_sectors) 188 188 { 189 + uint32_t sz = 0; 189 190 int i, part = 0, ret = 0; /* invalid by default */ 190 191 191 192 if (!mbr || le16_to_cpu(mbr->signature) != MSDOS_MBR_SIGNATURE) ··· 217 216 /* 218 217 * Protective MBRs take up the lesser of the whole disk 219 218 * or 2 TiB (32bit LBA), ignoring the rest of the disk. 219 + * Some partitioning programs, nonetheless, choose to set 220 + * the size to the maximum 32-bit limitation, disregarding 221 + * the disk size. 220 222 * 221 223 * Hybrid MBRs do not necessarily comply with this. 222 224 */ 223 225 if (ret == GPT_MBR_PROTECTIVE) { 224 - if (le32_to_cpu(mbr->partition_record[part].size_in_lba) != 225 - min((uint32_t) total_sectors - 1, 0xFFFFFFFF)) 226 + sz = le32_to_cpu(mbr->partition_record[part].size_in_lba); 227 + if (sz != (uint32_t) total_sectors - 1 && sz != 0xFFFFFFFF) 226 228 ret = 0; 227 229 } 228 230 done: