diff options
author | Masami Hiramatsu <mhiramat@redhat.com> | 2009-09-10 19:53:14 -0400 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2009-09-10 22:18:58 -0400 |
commit | 2fba0c8867af47f6455490e7b59e512dd180c027 (patch) | |
tree | b842519b73f0bed32dfab5bcf9b066622f01ff96 | |
parent | ad5cafcdb09c57008c990edd309c0a563b09f238 (diff) |
tracing/kprobes: Fix probe offset to be unsigned
Prohibit user to specify negative offset from symbols.
Since kprobe.offset is unsigned int, the offset must be always positive
value.
Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jason Baron <jbaron@redhat.com>
Cc: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <20090910235314.22412.64631.stgit@dhcp-100-2-132.bos.redhat.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
-rw-r--r-- | Documentation/trace/kprobetrace.txt | 14 | ||||
-rw-r--r-- | kernel/trace/trace_kprobe.c | 19 |
2 files changed, 14 insertions, 19 deletions
diff --git a/Documentation/trace/kprobetrace.txt b/Documentation/trace/kprobetrace.txt index 3de751747164..db5531865648 100644 --- a/Documentation/trace/kprobetrace.txt +++ b/Documentation/trace/kprobetrace.txt | |||
@@ -25,15 +25,15 @@ probe events via /sys/kernel/debug/tracing/events/kprobes/<EVENT>/filter. | |||
25 | 25 | ||
26 | Synopsis of kprobe_events | 26 | Synopsis of kprobe_events |
27 | ------------------------- | 27 | ------------------------- |
28 | p[:EVENT] SYMBOL[+offs|-offs]|MEMADDR [FETCHARGS] : Set a probe | 28 | p[:EVENT] SYMBOL[+offs]|MEMADDR [FETCHARGS] : Set a probe |
29 | r[:EVENT] SYMBOL[+0] [FETCHARGS] : Set a return probe | 29 | r[:EVENT] SYMBOL[+0] [FETCHARGS] : Set a return probe |
30 | 30 | ||
31 | EVENT : Event name. If omitted, the event name is generated | 31 | EVENT : Event name. If omitted, the event name is generated |
32 | based on SYMBOL+offs or MEMADDR. | 32 | based on SYMBOL+offs or MEMADDR. |
33 | SYMBOL[+offs|-offs] : Symbol+offset where the probe is inserted. | 33 | SYMBOL[+offs] : Symbol+offset where the probe is inserted. |
34 | MEMADDR : Address where the probe is inserted. | 34 | MEMADDR : Address where the probe is inserted. |
35 | 35 | ||
36 | FETCHARGS : Arguments. Each probe can have up to 128 args. | 36 | FETCHARGS : Arguments. Each probe can have up to 128 args. |
37 | %REG : Fetch register REG | 37 | %REG : Fetch register REG |
38 | sN : Fetch Nth entry of stack (N >= 0) | 38 | sN : Fetch Nth entry of stack (N >= 0) |
39 | sa : Fetch stack address. | 39 | sa : Fetch stack address. |
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 19a6de63b44b..c24b7e9d97c4 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c | |||
@@ -210,7 +210,7 @@ static __kprobes const char *probe_symbol(struct trace_probe *tp) | |||
210 | return tp->symbol ? tp->symbol : "unknown"; | 210 | return tp->symbol ? tp->symbol : "unknown"; |
211 | } | 211 | } |
212 | 212 | ||
213 | static __kprobes long probe_offset(struct trace_probe *tp) | 213 | static __kprobes unsigned int probe_offset(struct trace_probe *tp) |
214 | { | 214 | { |
215 | return (probe_is_return(tp)) ? tp->rp.kp.offset : tp->kp.offset; | 215 | return (probe_is_return(tp)) ? tp->rp.kp.offset : tp->kp.offset; |
216 | } | 216 | } |
@@ -380,7 +380,7 @@ end: | |||
380 | } | 380 | } |
381 | 381 | ||
382 | /* Split symbol and offset. */ | 382 | /* Split symbol and offset. */ |
383 | static int split_symbol_offset(char *symbol, long *offset) | 383 | static int split_symbol_offset(char *symbol, unsigned long *offset) |
384 | { | 384 | { |
385 | char *tmp; | 385 | char *tmp; |
386 | int ret; | 386 | int ret; |
@@ -389,16 +389,11 @@ static int split_symbol_offset(char *symbol, long *offset) | |||
389 | return -EINVAL; | 389 | return -EINVAL; |
390 | 390 | ||
391 | tmp = strchr(symbol, '+'); | 391 | tmp = strchr(symbol, '+'); |
392 | if (!tmp) | ||
393 | tmp = strchr(symbol, '-'); | ||
394 | |||
395 | if (tmp) { | 392 | if (tmp) { |
396 | /* skip sign because strict_strtol doesn't accept '+' */ | 393 | /* skip sign because strict_strtol doesn't accept '+' */ |
397 | ret = strict_strtol(tmp + 1, 0, offset); | 394 | ret = strict_strtoul(tmp + 1, 0, offset); |
398 | if (ret) | 395 | if (ret) |
399 | return ret; | 396 | return ret; |
400 | if (*tmp == '-') | ||
401 | *offset = -(*offset); | ||
402 | *tmp = '\0'; | 397 | *tmp = '\0'; |
403 | } else | 398 | } else |
404 | *offset = 0; | 399 | *offset = 0; |
@@ -520,7 +515,7 @@ static int create_trace_probe(int argc, char **argv) | |||
520 | { | 515 | { |
521 | /* | 516 | /* |
522 | * Argument syntax: | 517 | * Argument syntax: |
523 | * - Add kprobe: p[:EVENT] SYMBOL[+OFFS|-OFFS]|ADDRESS [FETCHARGS] | 518 | * - Add kprobe: p[:EVENT] SYMBOL[+OFFS]|ADDRESS [FETCHARGS] |
524 | * - Add kretprobe: r[:EVENT] SYMBOL[+0] [FETCHARGS] | 519 | * - Add kretprobe: r[:EVENT] SYMBOL[+0] [FETCHARGS] |
525 | * Fetch args: | 520 | * Fetch args: |
526 | * aN : fetch Nth of function argument. (N:0-) | 521 | * aN : fetch Nth of function argument. (N:0-) |
@@ -539,7 +534,7 @@ static int create_trace_probe(int argc, char **argv) | |||
539 | int i, ret = 0; | 534 | int i, ret = 0; |
540 | int is_return = 0; | 535 | int is_return = 0; |
541 | char *symbol = NULL, *event = NULL; | 536 | char *symbol = NULL, *event = NULL; |
542 | long offset = 0; | 537 | unsigned long offset = 0; |
543 | void *addr = NULL; | 538 | void *addr = NULL; |
544 | 539 | ||
545 | if (argc < 2) | 540 | if (argc < 2) |
@@ -605,7 +600,7 @@ static int create_trace_probe(int argc, char **argv) | |||
605 | 600 | ||
606 | if (tp->symbol) { | 601 | if (tp->symbol) { |
607 | kp->symbol_name = tp->symbol; | 602 | kp->symbol_name = tp->symbol; |
608 | kp->offset = offset; | 603 | kp->offset = (unsigned int)offset; |
609 | } else | 604 | } else |
610 | kp->addr = addr; | 605 | kp->addr = addr; |
611 | 606 | ||
@@ -675,7 +670,7 @@ static int probes_seq_show(struct seq_file *m, void *v) | |||
675 | seq_printf(m, ":%s", tp->call.name); | 670 | seq_printf(m, ":%s", tp->call.name); |
676 | 671 | ||
677 | if (tp->symbol) | 672 | if (tp->symbol) |
678 | seq_printf(m, " %s%+ld", probe_symbol(tp), probe_offset(tp)); | 673 | seq_printf(m, " %s+%u", probe_symbol(tp), probe_offset(tp)); |
679 | else | 674 | else |
680 | seq_printf(m, " 0x%p", probe_address(tp)); | 675 | seq_printf(m, " 0x%p", probe_address(tp)); |
681 | 676 | ||