Skip to content

Commit

Permalink
tracing/kprobe: Fix handling of C-unlike argument names
Browse files Browse the repository at this point in the history
Check the argument name whether it is invalid (not C-like symbol name). This
makes event format simple.

Reported-by: Srikar 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: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Masami Hiramatsu authored and Arnaldo Carvalho de Melo committed Sep 8, 2010
1 parent aba9159 commit da34634
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions kernel/trace/trace_kprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs);
static int kretprobe_dispatcher(struct kretprobe_instance *ri,
struct pt_regs *regs);

/* Check the name is good for event/group */
static int check_event_name(const char *name)
/* Check the name is good for event/group/fields */
static int is_good_name(const char *name)
{
if (!isalpha(*name) && *name != '_')
return 0;
Expand Down Expand Up @@ -557,7 +557,7 @@ static struct trace_probe *alloc_trace_probe(const char *group,
else
tp->rp.kp.pre_handler = kprobe_dispatcher;

if (!event || !check_event_name(event)) {
if (!event || !is_good_name(event)) {
ret = -EINVAL;
goto error;
}
Expand All @@ -567,7 +567,7 @@ static struct trace_probe *alloc_trace_probe(const char *group,
if (!tp->call.name)
goto error;

if (!group || !check_event_name(group)) {
if (!group || !is_good_name(group)) {
ret = -EINVAL;
goto error;
}
Expand Down Expand Up @@ -883,7 +883,7 @@ static int create_trace_probe(int argc, char **argv)
int i, ret = 0;
int is_return = 0, is_delete = 0;
char *symbol = NULL, *event = NULL, *group = NULL;
char *arg, *tmp;
char *arg;
unsigned long offset = 0;
void *addr = NULL;
char buf[MAX_EVENT_NAME_LEN];
Expand Down Expand Up @@ -1012,9 +1012,13 @@ static int create_trace_probe(int argc, char **argv)
ret = -ENOMEM;
goto error;
}
tmp = strchr(tp->args[i].name, ':');
if (tmp)
*tmp = '_'; /* convert : to _ */

if (!is_good_name(tp->args[i].name)) {
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)) {
pr_info("Argument[%d] name '%s' conflicts with "
Expand Down

0 comments on commit da34634

Please sign in to comment.