Browse Source

block/partitions/efi.c: treat size mismatch as a warning, not an error

In commit 27a7c64217 ("partitions/efi: account for pmbr size in lba")
we started treating bad sizes in lba field of the partition that has the
0xEE (GPT protective) as errors.

However, we may run into these "bad sizes" in the real world if someone
uses dd to copy an image from a smaller disk to a bigger disk.  Since
this case used to work (even without using force_gpt), keep it working
and treat the size mismatch as a warning instead of an error.

Reported-by: Josh Triplett <>
Reported-by: Sean Paul <>
Signed-off-by: Doug Anderson <>
Reviewed-by: Josh Triplett <>
Acked-by: Davidlohr Bueso <>
Tested-by: Artem Bityutskiy <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
Doug Anderson 7 years ago
committed by Linus Torvalds
1 changed files with 6 additions and 1 deletions
  1. +6

+ 6
- 1
block/partitions/efi.c View File

@ -222,11 +222,16 @@ check_hybrid:
* the disk size.
* Hybrid MBRs do not necessarily comply with this.
* Consider a bad value here to be a warning to support dd'ing
* an image from a smaller disk to a larger disk.
if (ret == GPT_MBR_PROTECTIVE) {
sz = le32_to_cpu(mbr->partition_record[part].size_in_lba);
if (sz != (uint32_t) total_sectors - 1 && sz != 0xFFFFFFFF)
ret = 0;
pr_debug("GPT: mbr size in lba (%u) different than whole disk (%u).\n",
sz, min_t(uint32_t,
total_sectors - 1, 0xFFFFFFFF));
return ret;