The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Doug Anderson <dianders@chromium.org>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Jens Axboe <axboe@kernel.dk>, Karel Zak <kzak@redhat.com>,
	Matt Fleming <matt.fleming@intel.com>,
	Sean Paul <seanpaul@chromium.org>,
	Olof Johansson <olof@lixom.net>,
	Bill Richardson <wfrichar@chromium.org>,
	Josh Triplett <josh@joshtriplett.org>,
	Doug Anderson <dianders@chromium.org>,
	Davidlohr Bueso <davidlohr@hp.com>
Subject: [PATCH] partitions/efi: treat size mismatch as a warning, not an error
Date: Thu, 10 Oct 2013 16:28:22 -0700	[thread overview]
Message-ID: <1381447702-6240-1-git-send-email-dianders@chromium.org> (raw)
In-Reply-To: <20131009232642.GA12776@jtriplet-mobl1>

In (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>
---
 block/partitions/efi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/block/partitions/efi.c b/block/partitions/efi.c
index 1eb09ee..ac23dc1 100644
--- a/block/partitions/efi.c
+++ b/block/partitions/efi.c
@@ -222,11 +222,15 @@ 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 bigger 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_warn("%s: mbr size mismatch (%u != %u)\n", __func__,
+				sz, (uint32_t)((uint32_t) total_sectors - 1));
 	}
 done:
 	return ret;
-- 
1.8.4


  parent reply	other threads:[~2013-10-10 23:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-09 23:26 Regression parsing GPT (EFI) partition tables Josh Triplett
2013-10-10  0:37 ` Davidlohr Bueso
2013-10-10 20:15   ` Doug Anderson
2013-10-10 21:26     ` Davidlohr Bueso
2013-10-10 21:53       ` Bill Richardson
2013-10-10 22:31         ` Davidlohr Bueso
2013-10-10 23:40           ` Doug Anderson
2013-10-10 22:29       ` Doug Anderson
2013-10-10 22:49         ` Davidlohr Bueso
2013-10-10 23:28 ` Doug Anderson [this message]
2013-10-11  0:25   ` [PATCH] partitions/efi: treat size mismatch as a warning, not an error Josh Triplett
2013-10-11  0:31   ` Davidlohr Bueso
2013-10-11 15:48     ` Doug Anderson
2013-10-11  9:51   ` Karel Zak
2013-10-11 15:53     ` Doug Anderson
2013-10-11 15:47   ` [PATCH v2] " Doug Anderson
2013-10-11 16:11     ` Davidlohr Bueso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1381447702-6240-1-git-send-email-dianders@chromium.org \
    --to=dianders@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=davidlohr@hp.com \
    --cc=josh@joshtriplett.org \
    --cc=kzak@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt.fleming@intel.com \
    --cc=olof@lixom.net \
    --cc=seanpaul@chromium.org \
    --cc=wfrichar@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox