mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch] perf: tui: Fix segfault when drawing out-of-bounds jumps
@ 2013-01-12  0:00 Frederik Deweerdt
  2013-01-14 13:44 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 4+ messages in thread
From: Frederik Deweerdt @ 2013-01-12  0:00 UTC (permalink / raw)
  To: namhyung, acme; +Cc: linux-kernel

Hi,

When perf.data contains out-of-symbol jumps,
annotate_browser__mark_jump_targets() correctly avoids marking
out-of-symbol jump targets. However, when moving the cursor on one of
said jumps, annotate_browser__draw_current_jump() will end up with a
bogus 'target' pointer, causing a bogus memory access when dereferencing
'bcursor' or 'btarget'

The following patch performs the same check as mark_jump_targets()
in order to avoid drawing the bogus jump.

Regards,
Frederik

Signed-off-by: Frederik Deweerdt <frederik.deweerdt@xprog.eu>

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 5dab3ca..8b84246 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -195,8 +195,9 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)
 	if (strstr(sym->name, "@plt"))
 		return;
 
-	if (!cursor || !cursor->ins || !ins__is_jump(cursor->ins) ||
-	    !disasm_line__has_offset(cursor))
+	if (!cursor || !cursor->ins || !ins__is_jump(cursor->ins)
+	    || !disasm_line__has_offset(cursor)
+	    || cursor->ops.target.offset >= symbol__size(sym))
 		return;
 
 	target = ab->offsets[cursor->ops.target.offset];

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-01-25 11:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-12  0:00 [patch] perf: tui: Fix segfault when drawing out-of-bounds jumps Frederik Deweerdt
2013-01-14 13:44 ` Arnaldo Carvalho de Melo
2013-01-14 19:47   ` Frederik Deweerdt
2013-01-25 11:50     ` [tip:perf/core] perf annotate browser: " tip-bot for Frederik Deweerdt

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

Powered by JetHome