public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Ulf Hermann <ulf.hermann@qt.io>, elfutils-devel@sourceware.org
Subject: Re: [PATCH 1/2 v2] Don't overflow in __libdw_in_section
Date: Thu, 14 Dec 2017 13:43:00 -0000	[thread overview]
Message-ID: <1513259021.15696.80.camel@klomp.org> (raw)
In-Reply-To: <5ae489eb-3981-24b4-294a-734b1c52731d@qt.io>

Hi Ulf,

(Meta, I have some trouble applying this with git am, it thinks the
patch is malformed. But I can apply by hand of course.)

On Fri, 2017-12-08 at 16:05 +0100, Ulf Hermann wrote:
> 
> +2017-05-09  Ulf Hermann  <ulf.hermann@qt.io>
> +
> +	* libdwP.h: Fix check for the upper border of the range in 
> __libdw_in_section.
> +
>   2017-11-03  Mark Wielaard  <mark@klomp.org>
>    	* dwarf_getlocation.c (__libdw_intern_expression): Handle
> diff --git a/libdw/libdwP.h b/libdw/libdwP.h
> index 78c0013..e092d8e 100644
> --- a/libdw/libdwP.h
> +++ b/libdw/libdwP.h
> @@ -643,7 +643,8 @@ __libdw_in_section (Dwarf *dbg, int sec_index,
>     if (data == NULL)
>       return false;
>     if (unlikely (addr < data->d_buf)
> -      || unlikely (data->d_size - (addr - data->d_buf) < size))
> +      || unlikely (data->d_size < size)
> +      || unlikely ((size_t)(addr - data->d_buf) > data->d_size -
> size))
>       {
>         __libdw_seterrno (DWARF_E_INVALID_OFFSET);
>         return false;

The transformation seems correct. But if we can overflow/underflow
here, do we have the same problem in __libdw_offset_in_section where we
  check data->d_size - offset < size, with offset a Dwarf_Off?

Thanks,

Mark

  reply	other threads:[~2017-12-14 13:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-08 15:05 Ulf Hermann
2017-12-14 13:43 ` Mark Wielaard [this message]
2017-12-14 13:55   ` Ulf Hermann
2017-12-20 18:05     ` Mark Wielaard
2017-12-21 13:47       ` Ulf Hermann
2017-12-21 20:22         ` Mark Wielaard

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=1513259021.15696.80.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=elfutils-devel@sourceware.org \
    --cc=ulf.hermann@qt.io \
    /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).