public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf annotate: Fix SEGV with assembly labels
@ 2013-07-11  4:33 Anton Blanchard
  0 siblings, 0 replies; only message in thread
From: Anton Blanchard @ 2013-07-11  4:33 UTC (permalink / raw)
  To: Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, David Ahern,
	Pekka Enberg
  Cc: linux-kernel


I'm getting a SEGV when running perf annotate on a ppc64 box. The
objdump -S output causing the SEGV looks like:

        b       .ret_from_except_lite
c00000000000a508:       b       c00000000000a4d4 <.ret_from_except_lite>

1:      bl      .save_nvgprs
c00000000000a50c:       bl      c00000000000a110 <.save_nvgprs>

symbol__parse_objdump_line makes an effort to distinguish between
instruction addresses and assembly labels but the check is
insufficent.

In the above case we get line_ip = 1, and (line_ip - start) is
positive so our offset < 0 check does not catch it.

Fix this by adding an unsigned comparison against start.

Signed-off-by: Anton Blanchard <anton@samba.org>
Cc: <stable@kernel.org>
---

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index d102716..a791d23 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -809,7 +809,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, struct map *map,
 		    end = map__rip_2objdump(map, sym->end);
 
 		offset = line_ip - start;
-		if (offset < 0 || (u64)line_ip > end)
+		if (offset < 0 || (u64)line_ip < start || (u64)line_ip > end)
 			offset = -1;
 		else
 			parsed_line = tmp2 + 1;

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-07-11  4:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-11  4:33 [PATCH] perf annotate: Fix SEGV with assembly labels Anton Blanchard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox