All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephane Eranian <eranian@google.com>
To: linux-kernel@vger.kernel.org
Cc: acme@redhat.com, peterz@infradead.org, mingo@elte.hu
Subject: [PATCH] perf: add sanity check on addr in symbol__inc_addr_samples()
Date: Thu, 9 Feb 2012 11:30:16 +0100	[thread overview]
Message-ID: <20120209103016.GA1999@quad> (raw)


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.
    
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;

             reply	other threads:[~2012-02-09 10:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-09 10:30 Stephane Eranian [this message]
2012-02-09 14:48 ` [PATCH] perf: add sanity check on addr in symbol__inc_addr_samples() 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
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=20120209103016.GA1999@quad \
    --to=eranian@google.com \
    --cc=acme@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.