Skip to content

Commit 87fc0ad

Browse files
dianderstorvalds
authored andcommitted
block/partitions/efi.c: treat size mismatch as a warning, not an error
In commit 27a7c64 ("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 <josh@joshtriplett.org> Reported-by: Sean Paul <seanpaul@chromium.org> Signed-off-by: Doug Anderson <dianders@chromium.org> Reviewed-by: Josh Triplett <josh@joshtriplett.org> Acked-by: Davidlohr Bueso <davidlohr@hp.com> Tested-by: Artem Bityutskiy <dedekind1@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ef5a22b commit 87fc0ad

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎block/partitions/efi.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,16 @@ static int is_pmbr_valid(legacy_mbr *mbr, sector_t total_sectors)
222222
* the disk size.
223223
*
224224
* Hybrid MBRs do not necessarily comply with this.
225+
*
226+
* Consider a bad value here to be a warning to support dd'ing
227+
* an image from a smaller disk to a larger disk.
225228
*/
226229
if (ret == GPT_MBR_PROTECTIVE) {
227230
sz = le32_to_cpu(mbr->partition_record[part].size_in_lba);
228231
if (sz != (uint32_t) total_sectors - 1 && sz != 0xFFFFFFFF)
229-
ret = 0;
232+
pr_debug("GPT: mbr size in lba (%u) different than whole disk (%u).\n",
233+
sz, min_t(uint32_t,
234+
total_sectors - 1, 0xFFFFFFFF));
230235
}
231236
done:
232237
return ret;

0 commit comments

Comments
 (0)