diff options
author | Prashanth Nageshappa <prashanth@linux.vnet.ibm.com> | 2012-02-24 02:41:39 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-02-29 16:29:45 -0500 |
commit | 26b7952494772f0e695271fbd6cf83a852f60f25 (patch) | |
tree | 168c92dc039cbd205b848c33da7020ea5b02a074 /tools/perf/util | |
parent | 30e68bcc67e41ab6dab4e4e1efc7ea8ca893c0af (diff) |
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.
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Link: http://lkml.kernel.org/r/4F473F33.4060409@linux.vnet.ibm.com
Signed-off-by: Prashanth Nageshappa <prashanth@linux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/probe-finder.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 5d732621a462..74bd2e63c4b4 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -672,7 +672,7 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf) | |||
672 | static int convert_to_trace_point(Dwarf_Die *sp_die, Dwarf_Addr paddr, | 672 | static int convert_to_trace_point(Dwarf_Die *sp_die, Dwarf_Addr paddr, |
673 | bool retprobe, struct probe_trace_point *tp) | 673 | bool retprobe, struct probe_trace_point *tp) |
674 | { | 674 | { |
675 | Dwarf_Addr eaddr; | 675 | Dwarf_Addr eaddr, highaddr; |
676 | const char *name; | 676 | const char *name; |
677 | 677 | ||
678 | /* Copy the name of probe point */ | 678 | /* Copy the name of probe point */ |
@@ -683,6 +683,16 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwarf_Addr paddr, | |||
683 | dwarf_diename(sp_die)); | 683 | dwarf_diename(sp_die)); |
684 | return -ENOENT; | 684 | return -ENOENT; |
685 | } | 685 | } |
686 | if (dwarf_highpc(sp_die, &highaddr) != 0) { | ||
687 | pr_warning("Failed to get end address of %s\n", | ||
688 | dwarf_diename(sp_die)); | ||
689 | return -ENOENT; | ||
690 | } | ||
691 | if (paddr > highaddr) { | ||
692 | pr_warning("Offset specified is greater than size of %s\n", | ||
693 | dwarf_diename(sp_die)); | ||
694 | return -EINVAL; | ||
695 | } | ||
686 | tp->symbol = strdup(name); | 696 | tp->symbol = strdup(name); |
687 | if (tp->symbol == NULL) | 697 | if (tp->symbol == NULL) |
688 | return -ENOMEM; | 698 | return -ENOMEM; |