linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "kzak@redhat.com" <kzak@redhat.com>
To: David Laight <David.Laight@ACULAB.COM>
Cc: 'Eugene Korenevsky' <ekorenevsky@gmail.com>,
	Davidlohr Bueso <dave@stgolabs.net>,
	"linux-efi@vger.kernel.org" <linux-efi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: Re: [PATCH v2] efi: take size of partition entry from GPT header
Date: Fri, 14 Sep 2018 13:07:03 +0200	[thread overview]
Message-ID: <20180914110703.ishvqwcpcf5ozihy@ws.net.home> (raw)
In-Reply-To: <2db38b2d1af34ab9b653c665d08872f1@AcuMS.aculab.com>

On Fri, Sep 14, 2018 at 09:01:48AM +0000, David Laight wrote:
> From: Eugene Korenevsky
> > Sent: 13 September 2018 20:48
> > 
> > > I suspect you also need a sanity check that the value isn't too small
> > > or stupidly large.
> > 
> > What would be the criterion for too large entries?
> 
> Anything larger than the maximum size of the full GPT table
> would be a start.
> Even something like 64k would stop later calculations going wrong.
> I presume there is a check elsewhere that the GPT table entries
> are all inside the disk area that was read?

is_gpt_valid() already contains 

        pt_size = (u64)le32_to_cpu((*gpt)->num_partition_entries) *
                le32_to_cpu((*gpt)->sizeof_partition_entry);
        if (pt_size > KMALLOC_MAX_SIZE)
                pr_debug("GUID Partition Table is too large: %llu > %lu bytes\n",
                (unsigned long long)pt_size, KMALLOC_MAX_SIZE);
                goto fail;
        }      

I guess it good enough for sanity check.

If you want to be really paranoid than you can also check that array
is possible to store to the expected area on the disk:

    pt_size <= (gpt->first_usable_lba - gpt->partition_entry_lba)

Note that is_gpt_valid() already compares the another LBAs with the 
device size to be sure GPT is no out of reality...

    Karel


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

  reply	other threads:[~2018-09-14 11:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-11 16:15 [PATCH v2] efi: take size of partition entry from GPT header Eugene Korenevsky
2018-09-11 16:27 ` Davidlohr Bueso
2018-09-11 16:42   ` Eugene Korenevsky
2018-09-11 22:56 ` kbuild test robot
2018-09-11 22:59 ` Ard Biesheuvel
2018-09-11 23:20 ` kbuild test robot
2018-09-12  8:38 ` Karel Zak
2018-09-13 13:06   ` David Laight
2018-09-13 19:48     ` Eugene Korenevsky
2018-09-14  9:01       ` David Laight
2018-09-14 11:07         ` kzak [this message]
2018-10-06 18:41           ` Eugene Korenevsky
2018-10-08 11:15             ` Karel Zak

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=20180914110703.ishvqwcpcf5ozihy@ws.net.home \
    --to=kzak@redhat.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=ard.biesheuvel@linaro.org \
    --cc=dave@stgolabs.net \
    --cc=ekorenevsky@gmail.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).