linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] elf: don't be afraid of overflow
Date: Tue, 12 Mar 2019 10:37:54 +0100	[thread overview]
Message-ID: <20190312093754.GB28905@amd> (raw)
In-Reply-To: <20190311171006.GA2141@avx2>

[-- Attachment #1: Type: text/plain, Size: 1168 bytes --]

On Mon 2019-03-11 20:10:06, Alexey Dobriyan wrote:
> On Mon, Mar 11, 2019 at 12:04:23PM +0100, Pavel Machek wrote:
> > On Mon 2019-02-04 23:27:15, Alexey Dobriyan wrote:
> > > Number of ELF program headers is 16-bit by spec, so total size
> > > comfortably fits into "unsigned int".
> > 
> > If it can't overflow, gcc should know too, and optimize checks
> > out... right?
> 
> Turns out it doesn't.

Tells me you are doing something wrong.

> > > @@ -429,13 +430,9 @@ static struct elf_phdr *load_elf_phdrs(struct elfhdr *elf_ex,
> > >  		goto out;
> > >  
> > >  	/* Sanity check the number of program headers... */
> > > -	if (elf_ex->e_phnum < 1 ||
> > > -		elf_ex->e_phnum > 65536U / sizeof(struct elf_phdr))
> > > -		goto out;
> > > -
> > >  	/* ...and their total size. */
> > 
> > This is just wrong. You removed check for zero, and I'm pretty sure
> > sizeof() is not 1, so this one can trigger, too.
> 
> No. ->e_phnum is 65535 max.

That does not invalidate my argument.

									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

      reply	other threads:[~2019-03-12  9:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-04 20:27 Alexey Dobriyan
2019-02-04 20:28 ` [PATCH 2/4] elf: use list_for_each_entry() Alexey Dobriyan
2019-02-04 20:28   ` [PATCH 3/4] elf: spread const a little Alexey Dobriyan
2019-02-04 20:33     ` [PATCH 4/4] elf: save allocation per exec Alexey Dobriyan
2019-02-12 15:49   ` [PATCH 2/4] elf: use list_for_each_entry() kbuild test robot
2019-02-12 16:21   ` kbuild test robot
2019-03-11 11:04 ` [PATCH 1/4] elf: don't be afraid of overflow Pavel Machek
2019-03-11 17:10   ` Alexey Dobriyan
2019-03-12  9:37     ` Pavel Machek [this message]

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=20190312093754.GB28905@amd \
    --to=pavel@ucw.cz \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH 1/4] elf: don'\''t be afraid of overflow' \
    /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

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).