From: Arnaldo Carvalho de Melo <acme@redhat.com>
To: Stephane Eranian <eranian@google.com>
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@elte.hu
Subject: Re: [PATCH] perf: add sanity check on addr in symbol__inc_addr_samples()
Date: Fri, 10 Feb 2012 11:46:46 -0200 [thread overview]
Message-ID: <20120210134646.GB4998@infradead.org> (raw)
In-Reply-To: <CABPqkBRdbn+UasvWgVco-NZ_LasFeG+7bLzTDVcQO-e6J+AW-Q@mail.gmail.com>
Em Thu, Feb 09, 2012 at 03:53:14PM +0100, Stephane Eranian escreveu:
> On Thu, Feb 9, 2012 at 3:48 PM, Arnaldo Carvalho de Melo
> <acme@redhat.com> wrote:
> > Em Thu, Feb 09, 2012 at 11:30:16AM +0100, Stephane Eranian escreveu:
> >>
> >> Check the value of addr against the bounds of the symbol.
> >> This is needed given we compute an offset:
> >> offset = addr - sym->start
> >>
> >> And we don't want the offset to become negative.
> >
> > I'll try and add a debug option to show the backtrace and values of
> > addr, sym, etc, so that we can fix the real problem.
> > I.e. this function shouldn't be receiving any such invalid addresses, as
> > the symbol lookup was done, the symbol was found to be this one, then
> > why it would be out of bounds at this point?!
> I tend to agree with you on this. But then I don't see why the first test
> was there.
Its wrong as well, we should leave it there, together with the new test,
but as:
BUG_ON(addr >= sym->end || addr < sym->start)
- Arnaldo
> > - Arnaldo
> >
> >> Signed-off-by: Stephane Eranian <eranian@google.com>
> >>
> >> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
> >> index 011ed26..8248d80 100644
> >> --- a/tools/perf/util/annotate.c
> >> +++ b/tools/perf/util/annotate.c
> >> @@ -64,7 +64,7 @@ int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
> >>
> >> pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map->unmap_ip(map, addr));
> >>
> >> - if (addr >= sym->end)
> >> + if (addr >= sym->end || addr < sym->start)
> >> return 0;
> >>
> >> offset = addr - sym->start;
next prev parent reply other threads:[~2012-02-10 13:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-09 10:30 Stephane Eranian
2012-02-09 14:48 ` Arnaldo Carvalho de Melo
2012-02-09 14:53 ` Stephane Eranian
2012-02-09 15:06 ` Sorin Dumitru
2012-02-10 14:20 ` Arnaldo Carvalho de Melo
2012-02-10 13:46 ` Arnaldo Carvalho de Melo [this message]
2012-02-10 13:49 ` Stephane Eranian
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=20120210134646.GB4998@infradead.org \
--to=acme@redhat.com \
--cc=eranian@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.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
all inboxes | Powered by JetHome®