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:54:05 -0500 [thread overview]
Message-ID: <20161206135405.GA29569@char.us.oracle.com> (raw)
In-Reply-To: <5846CD2A0200007800125B57@prv-mh.provo.novell.com>
On Tue, Dec 06, 2016 at 06:37:30AM -0700, Jan Beulich wrote:
> >>> On 06.12.16 at 14:27, <konrad.wilk@oracle.com> wrote:
> >> 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?
>
> Well - there was no such comment before on the equivalent (but
> slightly wrong) check which is being replaced here. If you really
> think such a comment should be added now, I can certainly (albeit
> a little reluctantly) do so - let me know.
It is up to you. I was thinking more in terms of somebody reading this
code and not realizing what we are checking for.
But maybe it is just me not having yet my coffee and other folks
looking at this would spot this right away.
>
> Jan
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-12-06 13:54 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
2016-12-06 13:37 ` Jan Beulich
2016-12-06 13:54 ` Konrad Rzeszutek Wilk [this message]
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=20161206135405.GA29569@char.us.oracle.com \
--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).