All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf annotate: fix 's' on source line when disasm is empty
@ 2021-07-05 16:15 Riccardo Mancini
  2021-07-05 17:52 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 2+ messages in thread
From: Riccardo Mancini @ 2021-07-05 16:15 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, Ian Rogers, Riccardo Mancini, Peter Zijlstra,
	Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Martin Liska, linux-perf-users, linux-kernel

If the disasm is empty, 's' should fail. Instead it seemingly works,
hiding the empty lines and causing an assertion error on the next
time annotate is called (from within perf report).
The problem is caused by a buffer overflow, caused by a wrong
exit condition in annotate_browser__find_next_asm_line, which checks
browser->b.top instead of browser->b.entries.

This patch fixes the issue, making annotate_browser__toggle_source
fail if the disasm is empty (nothing happens to the user).

Fixes: 6de249d66d2e
Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>
---
 tools/perf/ui/browsers/annotate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index f5509a958e38..5812a2214cc1 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -350,14 +350,14 @@ static struct annotation_line *annotate_browser__find_next_asm_line(
 	struct annotation_line *it = al;
 
 	/* find next asm line */
-	list_for_each_entry_continue(it, browser->b.top, node) {
+	list_for_each_entry_continue(it, browser->b.entries, node) {
 		if (it->idx_asm >= 0)
 			return it;
 	}
 
 	/* no asm line found forwards, try backwards */
 	it = al;
-	list_for_each_entry_continue_reverse(it, browser->b.top, node) {
+	list_for_each_entry_continue_reverse(it, browser->b.entries, node) {
 		if (it->idx_asm >= 0)
 			return it;
 	}
-- 
2.23.0


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

* Re: [PATCH] perf annotate: fix 's' on source line when disasm is empty
  2021-07-05 16:15 [PATCH] perf annotate: fix 's' on source line when disasm is empty Riccardo Mancini
@ 2021-07-05 17:52 ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-07-05 17:52 UTC (permalink / raw)
  To: Riccardo Mancini
  Cc: Namhyung Kim, Ian Rogers, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Martin Liska,
	linux-perf-users, linux-kernel

Em Mon, Jul 05, 2021 at 06:15:25PM +0200, Riccardo Mancini escreveu:
> If the disasm is empty, 's' should fail. Instead it seemingly works,
> hiding the empty lines and causing an assertion error on the next
> time annotate is called (from within perf report).
> The problem is caused by a buffer overflow, caused by a wrong
> exit condition in annotate_browser__find_next_asm_line, which checks
> browser->b.top instead of browser->b.entries.
> 
> This patch fixes the issue, making annotate_browser__toggle_source
> fail if the disasm is empty (nothing happens to the user).
> 
> Fixes: 6de249d66d2e

Next time please make the fixes be of this form:

Fixes: 6de249d66d2e7881 ("perf annotate: Allow 's' on source code lines")

⬢[acme@toolbox perf]$ git config core.abbrev 16
⬢[acme@toolbox perf]$ git config core.abbrev
16
⬢[acme@toolbox perf]$ head -2 ~/.gitconfig 
[core]
	abbrev = 16
⬢[acme@toolbox perf]$ 

Thanks, applied.

- Arnaldo

> Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>
> ---
>  tools/perf/ui/browsers/annotate.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
> index f5509a958e38..5812a2214cc1 100644
> --- a/tools/perf/ui/browsers/annotate.c
> +++ b/tools/perf/ui/browsers/annotate.c
> @@ -350,14 +350,14 @@ static struct annotation_line *annotate_browser__find_next_asm_line(
>  	struct annotation_line *it = al;
>  
>  	/* find next asm line */
> -	list_for_each_entry_continue(it, browser->b.top, node) {
> +	list_for_each_entry_continue(it, browser->b.entries, node) {
>  		if (it->idx_asm >= 0)
>  			return it;
>  	}
>  
>  	/* no asm line found forwards, try backwards */
>  	it = al;
> -	list_for_each_entry_continue_reverse(it, browser->b.top, node) {
> +	list_for_each_entry_continue_reverse(it, browser->b.entries, node) {
>  		if (it->idx_asm >= 0)
>  			return it;
>  	}
> -- 
> 2.23.0
> 

-- 

- Arnaldo

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

end of thread, other threads:[~2021-07-05 17:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-05 16:15 [PATCH] perf annotate: fix 's' on source line when disasm is empty Riccardo Mancini
2021-07-05 17:52 ` Arnaldo Carvalho de Melo

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.