Skip to contentSkip to conversation

perf probe: fix to initialize fname always before use it

PATCH In review Masami Hiramatsu 3 participants 4 messages Oct 11, 2013 – Oct 20, 2013 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf probe: fix to initialize fname always before use it

Fix perf probe --list to initialize fname local var always before use it. This may cause a SEGV if there is a probe which is in the function body but not in any inline function.

Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Namhyung Kim <[email protected]>
---
 tools/perf/util/probe-finder.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/probe-finder.c +1 -1
index c044052..e41b094 100644
@@ -1460,10 +1460,10 @@ int debuginfo__find_probe_point(struct debuginfo *self, unsigned long addr,
 			goto post;
 		}
 
+		fname = dwarf_decl_file(&spdie);
 		if (addr == (unsigned long)baseaddr) {
 			/* Function entry - Relative line number is 0 */
 			lineno = baseline;
-			fname = dwarf_decl_file(&spdie);
 			goto post;
 		}
 
#1 lore raw

Hi Arnaldo,

I've found a bug in my previous patch which was already picked in the perf/urgent branch. The buggy commit id is

e08cfd4bda7683cdbe6971c26cf23e2afdb1e7a8

And this is not related to the previous series of perf probe updates.

Thank you,

Quoted 29 lines · Masami Hiramatsu

Fix perf probe --list to initialize fname local var always before use it. This may cause a SEGV if there is a probe which is in the function body but not in any inline function.

Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Namhyung Kim <[email protected]>
---
 tools/perf/util/probe-finder.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/probe-finder.c +1 -1
index c044052..e41b094 100644
@@ -1460,10 +1460,10 @@ int debuginfo__find_probe_point(struct debuginfo *self, unsigned long addr,
 			goto post;
 		}
 
+		fname = dwarf_decl_file(&spdie);
 		if (addr == (unsigned long)baseaddr) {
 			/* Function entry - Relative line number is 0 */
 			lineno = baseline;
-			fname = dwarf_decl_file(&spdie);
 			goto post;
 		}
Signature · 4 lines
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: [email protected]
#2 lore raw

Em Fri, Oct 11, 2013 at 09:31:47PM +0900, Masami Hiramatsu escreveu:

Quoted 9 lines

Hi Arnaldo,

I've found a bug in my previous patch which was already picked in the perf/urgent branch. The buggy commit id is

e08cfd4bda7683cdbe6971c26cf23e2afdb1e7a8

And this is not related to the previous series of perf probe updates.

Ok, so it must go via perf/urgent or if that ends up not being anymore possible, via stable, will try the perf/urgent path today,

- Arnaldo

Quoted 40 lines

Thank you,

Quoted 29 lines · Masami Hiramatsu

Fix perf probe --list to initialize fname local var always before use it. This may cause a SEGV if there is a probe which is in the function body but not in any inline function.

Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Namhyung Kim <[email protected]>
---
 tools/perf/util/probe-finder.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/probe-finder.c +1 -1
index c044052..e41b094 100644
@@ -1460,10 +1460,10 @@ int debuginfo__find_probe_point(struct debuginfo *self, unsigned long addr,
 			goto post;
 		}
 
+		fname = dwarf_decl_file(&spdie);
 		if (addr == (unsigned long)baseaddr) {
 			/* Function entry - Relative line number is 0 */
 			lineno = baseline;
-			fname = dwarf_decl_file(&spdie);
 			goto post;
 		}
Signature · 4 lines
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: [email protected]
#3 lore raw

[tip:perf/urgent] perf probe: Fix to initialize fname always before use it

In reply to Masami Hiramatsu
perf probe: Fix to initialize fname always before use it
Commit-ID:  1b286bdd5b7684c681b63d5e75cada037064c315
Gitweb:     http://git.kernel.org/tip/1b286bdd5b7684c681b63d5e75cada037064c315
Author:     Masami Hiramatsu <[email protected]>
AuthorDate: Fri, 11 Oct 2013 12:23:17 +0000
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 15 Oct 2013 14:37:38 -0300

perf probe: Fix to initialize fname always before use it

Fix perf probe --list to initialize fname local var always before use it. This may cause a SEGV if there is a probe which is in the function body but not in any inline function.

Problem introduced in:

	commit e08cfd4bda76
	Author: Masami Hiramatsu <[email protected]>
	Date:   Mon Sep 30 18:21:44 2013 +0900

	    perf probe: Fix to find line information for probe list
---
 tools/perf/util/probe-finder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/probe-finder.c +1 -1
index c09e0a9..f069273 100644
@@ -1357,10 +1357,10 @@ int debuginfo__find_probe_point(struct debuginfo *self, unsigned long addr,
 			goto post;
 		}
 
+		fname = dwarf_decl_file(&spdie);
 		if (addr == (unsigned long)baseaddr) {
 			/* Function entry - Relative line number is 0 */
 			lineno = baseline;
-			fname = dwarf_decl_file(&spdie);
 			goto post;
 		}