Commit da34634f authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Arnaldo Carvalho de Melo

tracing/kprobe: Fix handling of C-unlike argument names

Check the argument name whether it is invalid (not C-like symbol name). This
makes event format simple.
Reported-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
LKML-Reference: <20100827113912.22882.62313.stgit@ltc236.sdl.hitachi.co.jp>
Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent aba91595
...@@ -514,8 +514,8 @@ static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs); ...@@ -514,8 +514,8 @@ static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs);
static int kretprobe_dispatcher(struct kretprobe_instance *ri, static int kretprobe_dispatcher(struct kretprobe_instance *ri,
struct pt_regs *regs); struct pt_regs *regs);
/* Check the name is good for event/group */ /* Check the name is good for event/group/fields */
static int check_event_name(const char *name) static int is_good_name(const char *name)
{ {
if (!isalpha(*name) && *name != '_') if (!isalpha(*name) && *name != '_')
return 0; return 0;
...@@ -557,7 +557,7 @@ static struct trace_probe *alloc_trace_probe(const char *group, ...@@ -557,7 +557,7 @@ static struct trace_probe *alloc_trace_probe(const char *group,
else else
tp->rp.kp.pre_handler = kprobe_dispatcher; tp->rp.kp.pre_handler = kprobe_dispatcher;
if (!event || !check_event_name(event)) { if (!event || !is_good_name(event)) {
ret = -EINVAL; ret = -EINVAL;
goto error; goto error;
} }
...@@ -567,7 +567,7 @@ static struct trace_probe *alloc_trace_probe(const char *group, ...@@ -567,7 +567,7 @@ static struct trace_probe *alloc_trace_probe(const char *group,
if (!tp->call.name) if (!tp->call.name)
goto error; goto error;
if (!group || !check_event_name(group)) { if (!group || !is_good_name(group)) {
ret = -EINVAL; ret = -EINVAL;
goto error; goto error;
} }
...@@ -883,7 +883,7 @@ static int create_trace_probe(int argc, char **argv) ...@@ -883,7 +883,7 @@ static int create_trace_probe(int argc, char **argv)
int i, ret = 0; int i, ret = 0;
int is_return = 0, is_delete = 0; int is_return = 0, is_delete = 0;
char *symbol = NULL, *event = NULL, *group = NULL; char *symbol = NULL, *event = NULL, *group = NULL;
char *arg, *tmp; char *arg;
unsigned long offset = 0; unsigned long offset = 0;
void *addr = NULL; void *addr = NULL;
char buf[MAX_EVENT_NAME_LEN]; char buf[MAX_EVENT_NAME_LEN];
...@@ -1012,9 +1012,13 @@ static int create_trace_probe(int argc, char **argv) ...@@ -1012,9 +1012,13 @@ static int create_trace_probe(int argc, char **argv)
ret = -ENOMEM; ret = -ENOMEM;
goto error; goto error;
} }
tmp = strchr(tp->args[i].name, ':');
if (tmp) if (!is_good_name(tp->args[i].name)) {
*tmp = '_'; /* convert : to _ */ pr_info("Invalid argument[%d] name: %s\n",
i, tp->args[i].name);
ret = -EINVAL;
goto error;
}
if (conflict_field_name(tp->args[i].name, tp->args, i)) { if (conflict_field_name(tp->args[i].name, tp->args, i)) {
pr_info("Argument[%d] name '%s' conflicts with " pr_info("Argument[%d] name '%s' conflicts with "
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment