lkml.org 
[lkml]   [2013]   [Jan]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] perf: tui: Fix segfault when drawing out-of-bounds jumps
Em Fri, Jan 11, 2013 at 07:00:43PM -0500, Frederik Deweerdt escreveu:
> 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.

Thanks, I'll apply this one later today and introduce a
disasm_line__is_valid_jump(cursor) routine to be used in both mark and
draw routines, if you don't do it first :-)

- Arnaldo

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


\
 
 \ /
  Last update: 2013-01-14 15:43    [W:0.473 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site