perf - ensure offset provided during probe addition is not greater than function length
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 perf - ensure offset provided during probe addition is not greater than function length
perf probe allows kprobe to be inserted at any offset from a function start, which results in adding kprobes to unintended location. (example: perf probe do_fork+10000 is allowed even though size of do_fork is ~904)
This patch will ensure probe addition fails when the offset specified is greater than size of the function.
---
tools/perf/util/probe-finder.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-)
tools/perf/util/probe-finder.c +11 -1
@@ -672,7 +672,7 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf)static int convert_to_trace_point (Dwarf_Die *sp_die,Dwarf_Addr paddr,bool retprobe,struct probe_trace_point *tp) { -Dwarf_Addr eaddr; +Dwarf_Addr eaddr, highaddr;const char *name;/* Copy the name of probe point */
@@ -683,6 +683,16 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwarf_Addr paddr, dwarf_diename(sp_die));return -ENOENT ; } +if (dwarf_highpc (sp_die, &highaddr) !=0 ) { +pr_warning ("Failed to get end address of %s\n" , +dwarf_diename (sp_die)); +return -ENOENT ; + } +if (paddr > highaddr) { +pr_warning ("Offset specified is greater than size of %s\n" , +dwarf_diename (sp_die)); +return -EINVAL ; + } tp->symbol =strdup (name);if (tp->symbol ==NULL )return -ENOMEM ;
Quoted 10 lines · Prashanth Nageshappa
perf probe allows kprobe to be inserted at any offset from a function start, which results in adding kprobes to unintended location. (example: perf probe do_fork+10000 is allowed even though size of
do_forkis ~904)This patch will ensure probe addition fails when the offset specified is greater than size of the function.
Signed-off-by Prashanth Nageshappa <[email protected]>
This seems good to me.
Thank you,
Quoted 36 lines
---
tools/perf/util/probe-finder.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-)tools/perf/util/probe-finder.c +11
-1@@ -672,7 +672,7 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf)static int convert_to_trace_point (Dwarf_Die *sp_die,Dwarf_Addr paddr,bool retprobe,struct probe_trace_point *tp) { -Dwarf_Addr eaddr; +Dwarf_Addr eaddr, highaddr;const char *name;/* Copy the name of probe point */ @@ -683,6 +683,16 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwarf_Addr paddr, dwarf_diename(sp_die));return -ENOENT ; } +if (dwarf_highpc (sp_die, &highaddr) !=0 ) { +pr_warning ("Failed to get end address of %s\n" , +dwarf_diename (sp_die)); +return -ENOENT ; + } +if (paddr > highaddr) { +pr_warning ("Offset specified is greater than size of %s\n" , +dwarf_diename (sp_die)); +return -EINVAL ; + } tp->symbol =strdup (name);if (tp->symbol ==NULL )return -ENOMEM ;
Signature · 4 lines
Masami HIRAMATSU Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: [email protected]
Can you please pick up this patch?
Quoted 56 lines · Masami Hiramatsu
Quoted 10 lines · Prashanth Nageshappa
perf probe allows kprobe to be inserted at any offset from a function start, which results in adding kprobes to unintended location. (example: perf probe do_fork+10000 is allowed even though size of
do_forkis ~904)This patch will ensure probe addition fails when the offset specified is greater than size of the function.
Signed-off-by Prashanth Nageshappa <[email protected]>This seems good to me.
Acked-by Masami Hiramatsu <[email protected]>Thank you,
Quoted 36 lines
---
tools/perf/util/probe-finder.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-)tools/perf/util/probe-finder.c +11
-1@@ -672,7 +672,7 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf)static int convert_to_trace_point (Dwarf_Die *sp_die,Dwarf_Addr paddr,bool retprobe,struct probe_trace_point *tp) { -Dwarf_Addr eaddr; +Dwarf_Addr eaddr, highaddr;const char *name;/* Copy the name of probe point */ @@ -683,6 +683,16 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwarf_Addr paddr, dwarf_diename(sp_die));return -ENOENT ; } +if (dwarf_highpc (sp_die, &highaddr) !=0 ) { +pr_warning ("Failed to get end address of %s\n" , +dwarf_diename (sp_die)); +return -ENOENT ; + } +if (paddr > highaddr) { +pr_warning ("Offset specified is greater than size of %s\n" , +dwarf_diename (sp_die)); +return -EINVAL ; + } tp->symbol =strdup (name);if (tp->symbol ==NULL )return -ENOMEM ;
Em Fri, Feb 24, 2012 at 05:03:03PM +0530, Prashanth Nageshappa escreveu:
Quoted 1 line
Can you please pick up this patch?
I'll do it, thanks,
- Arnaldo
Quoted 59 lines · Masami Hiramatsu
Quoted 57 lines
Quoted 10 lines · Prashanth Nageshappa
perf probe allows kprobe to be inserted at any offset from a function start, which results in adding kprobes to unintended location. (example: perf probe do_fork+10000 is allowed even though size of
do_forkis ~904)This patch will ensure probe addition fails when the offset specified is greater than size of the function.
Signed-off-by Prashanth Nageshappa <[email protected]>This seems good to me.
Acked-by Masami Hiramatsu <[email protected]>Thank you,
Quoted 36 lines
---
tools/perf/util/probe-finder.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-)tools/perf/util/probe-finder.c +11
-1@@ -672,7 +672,7 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf)static int convert_to_trace_point (Dwarf_Die *sp_die,Dwarf_Addr paddr,bool retprobe,struct probe_trace_point *tp) { -Dwarf_Addr eaddr; +Dwarf_Addr eaddr, highaddr;const char *name;/* Copy the name of probe point */ @@ -683,6 +683,16 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwarf_Addr paddr, dwarf_diename(sp_die));return -ENOENT ; } +if (dwarf_highpc (sp_die, &highaddr) !=0 ) { +pr_warning ("Failed to get end address of %s\n" , +dwarf_diename (sp_die)); +return -ENOENT ; + } +if (paddr > highaddr) { +pr_warning ("Offset specified is greater than size of %s\n" , +dwarf_diename (sp_die)); +return -EINVAL ; + } tp->symbol =strdup (name);if (tp->symbol ==NULL )return -ENOMEM ;
[tip:perf/urgent] perf probe: Ensure offset provided is not greater than function length
In reply to Prashanth NageshappaCommit-ID: 26b7952494772f0e695271fbd6cf83a852f60f25 Gitweb: http://git.kernel.org/tip/26b7952494772f0e695271fbd6cf83a852f60f25 Author: Prashanth Nageshappa <[email protected]> AuthorDate: Fri, 24 Feb 2012 13:11:39 +0530 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 29 Feb 2012 18:29:45 -0300
perf probe: Ensure offset provided is not greater than function length
The perf probe command allows kprobe to be inserted at any offset from a function start, which results in adding kprobes to unintended location.
Example: perf probe do_fork+10000 is allowed even though size of do_fork is ~904.
This patch will ensure probe addition fails when the offset specified is greater than size of the function.
--- tools/perf/util/probe-finder.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-)
tools/perf/util/probe-finder.c +11 -1
@@ -672,7 +672,7 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf)static int convert_to_trace_point (Dwarf_Die *sp_die,Dwarf_Addr paddr,bool retprobe,struct probe_trace_point *tp) { -Dwarf_Addr eaddr; +Dwarf_Addr eaddr, highaddr;const char *name;/* Copy the name of probe point */
@@ -683,6 +683,16 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwarf_Addr paddr, dwarf_diename(sp_die));return -ENOENT ; } +if (dwarf_highpc (sp_die, &highaddr) !=0 ) { +pr_warning ("Failed to get end address of %s\n" , +dwarf_diename (sp_die)); +return -ENOENT ; + } +if (paddr > highaddr) { +pr_warning ("Offset specified is greater than size of %s\n" , +dwarf_diename (sp_die)); +return -EINVAL ; + } tp->symbol =strdup (name);if (tp->symbol ==NULL )return -ENOMEM ;