xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
	xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 4/4] libelf: treat phdr and shdr similarly
Date: Tue, 6 Dec 2016 08:27:31 -0500	[thread overview]
Message-ID: <20161206132731.GD29246@localhost.localdomain> (raw)
In-Reply-To: <5846B4B802000078001259F1@prv-mh.provo.novell.com>

. snip..
All that above makes sense (and please put Reviewed-by from me on it), but this:

>  unsigned elf_shdr_count(struct elf_binary *elf)
>  {
>      unsigned count = elf_uval(elf, elf->ehdr, e_shnum);
> -    uint64_t max = elf->size / sizeof(Elf32_Shdr);
> +    uint64_t max;
>  
> +    if ( !count )
> +        return 0;
> +    max = elf->size / elf_uval(elf, elf->ehdr, e_shentsize);

Seems incorrect. The elf->size is the size of the image - including
the ELF and the data it contains.

But I presume the check is rather to make sure that if there
is no data, just an ELF sections  - that we don't roll over it.

In which case perhaps adding a comment saying:

/* If file has nothing but ELF this will catch us from rolling over the end.*/

or such?

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2016-12-06 13:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-06 11:46 [PATCH 0/4] libelf: misc adjustments Jan Beulich
2016-12-06 11:51 ` [PATCH 1/4] libelf: section index 0 is special Jan Beulich
2016-12-06 13:09   ` Konrad Rzeszutek Wilk
2016-12-06 13:51   ` Roger Pau Monné
2016-12-06 11:52 ` [PATCH 2/4] libelf: use UINT_MAX Jan Beulich
2016-12-06 13:09   ` Konrad Rzeszutek Wilk
2016-12-06 13:49   ` Roger Pau Monné
2016-12-06 14:09     ` Jan Beulich
2016-12-06 14:42       ` Roger Pau Monné
2016-12-06 11:52 ` [PATCH 3/4] libelf: type adjustments Jan Beulich
2016-12-06 13:14   ` Konrad Rzeszutek Wilk
2016-12-06 13:55   ` Roger Pau Monné
2016-12-06 11:53 ` [PATCH 4/4] libelf: treat phdr and shdr similarly Jan Beulich
2016-12-06 13:27   ` Konrad Rzeszutek Wilk [this message]
2016-12-06 13:37     ` Jan Beulich
2016-12-06 13:54       ` Konrad Rzeszutek Wilk
2016-12-06 14:41   ` Roger Pau Monné

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=20161206132731.GD29246@localhost.localdomain \
    --to=konrad.wilk@oracle.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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).