public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Josh Stone <jistone@redhat.com>, elfutils-devel@sourceware.org
Subject: Re: failed reading "Smallest x86 ELF Hello World"
Date: Fri, 13 Oct 2017 15:09:00 -0000	[thread overview]
Message-ID: <1507907383.339.42.camel@klomp.org> (raw)
In-Reply-To: <1507143353.9961.25.camel@klomp.org>

On Wed, 2017-10-04 at 20:55 +0200, Mark Wielaard wrote:
> The first issue is indeed that almost anything that goes wrong when
> setting up the initial Elf handle ends up being described as
> ELF_E_INVALID_FILE. Which is not always the correct error code. So I
> introduced ELF_E_INVALID_ELF which indicates it is bad ELF data being
> encountered and not just the inability to read the data from the file
> descriptor. Also in a couple of cases we didn't explicitly set the
> libelf errno to indicate what really went wrong. I made sure we
> always
> do now.
> 
>   libelf: Add ELF_E_INVALID_ELF error value.
>
> [...]
>
> But while auditing this code it is clear we go out of our way to get
> the section (count) making sure we don't touch any bad data. If there
> is a change we might read anything bad from the (mmapped) file then
> we
> explicitly set the elf->state.elf[64|32].scns.cnt to zero. Which is
> respected throughout libelf whenever we try to touch section headers.
> Except... during the initial read we double check e_shoff is sane and
> error out early. Even though the code right below it explicitly
> doesn't
> use it when scncnt is zero. So we can fix this sanity check.
> 
>   libelf: Don't error out when sanity checking e_shoff if scncnt is
> zero.

I pushed both these commits to master now.

Cheers,

Mark

      parent reply	other threads:[~2017-10-13 15:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-28 19:06 Josh Stone
2017-10-04 18:55 ` Mark Wielaard
2017-10-04 18:57   ` [PATCH 1/2] libelf: Add ELF_E_INVALID_ELF error value Mark Wielaard
2017-10-04 18:57     ` [PATCH 2/2] libelf: Don't error out when sanity checking e_shoff if scncnt is zero Mark Wielaard
2017-10-13 15:09   ` Mark Wielaard [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=1507907383.339.42.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=elfutils-devel@sourceware.org \
    --cc=jistone@redhat.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).