tracing/filters: allow user input integer to be oct or hex
authorLi Zefan <lizf@cn.fujitsu.com>
Sat, 11 Apr 2009 07:52:51 +0000 (15:52 +0800)
committerIngo Molnar <mingo@elte.hu>
Sun, 12 Apr 2009 09:59:28 +0000 (11:59 +0200)
Before patch:

 # echo 'parent_pid == 0x10' > events/sched/sched_process_fork/filter
 # cat sched/sched_process_fork/filter
 parent_pid == 0

After patch:

 # cat sched/sched_process_fork/filter
 parent_pid == 16

Also check the input more strictly.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Tom Zanussi <tzanussi@gmail.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <49E04C53.4010600@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/trace/trace_events_filter.c

index 9d2162fd2305ea94001ff2f3da49f58e1bb30fe4..49b3ef54ec46844bc66cfbfaf63f9336ab396f39 100644 (file)
@@ -419,12 +419,13 @@ int filter_parse(char **pbuf, struct filter_pred *pred)
        if (!pred->field_name)
                return -ENOMEM;
 
-       pred->val = simple_strtoull(val_str, &tmp, 10);
+       pred->val = simple_strtoull(val_str, &tmp, 0);
        if (tmp == val_str) {
                pred->str_val = kstrdup(val_str, GFP_KERNEL);
                if (!pred->str_val)
                        return -ENOMEM;
-       }
+       } else if (*tmp != '\0')
+               return -EINVAL;
 
        return 0;
 }