mirror of https://gitee.com/openkylin/linux.git
tracing: Fix event trigger to accept redundant spaces
Fix the event trigger to accept redundant spaces in
the trigger input.
For example, these return -EINVAL
echo " traceon" > events/ftrace/print/trigger
echo "traceon if common_pid == 0" > events/ftrace/print/trigger
echo "disable_event:kmem:kmalloc " > events/ftrace/print/trigger
But these are hard to find what is wrong.
To fix this issue, use skip_spaces() to remove spaces
in front of actual tokens, and set NULL if there is no
token.
Link: http://lkml.kernel.org/r/159262476352.185015.5261566783045364186.stgit@devnote2
Cc: Tom Zanussi <zanussi@kernel.org>
Cc: stable@vger.kernel.org
Fixes: 85f2b08268
("tracing: Add basic event trigger framework")
Reviewed-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
parent
6c95503c29
commit
6784beada6
|
@ -216,11 +216,17 @@ static int event_trigger_regex_open(struct inode *inode, struct file *file)
|
||||||
|
|
||||||
int trigger_process_regex(struct trace_event_file *file, char *buff)
|
int trigger_process_regex(struct trace_event_file *file, char *buff)
|
||||||
{
|
{
|
||||||
char *command, *next = buff;
|
char *command, *next;
|
||||||
struct event_command *p;
|
struct event_command *p;
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
|
|
||||||
|
next = buff = skip_spaces(buff);
|
||||||
command = strsep(&next, ": \t");
|
command = strsep(&next, ": \t");
|
||||||
|
if (next) {
|
||||||
|
next = skip_spaces(next);
|
||||||
|
if (!*next)
|
||||||
|
next = NULL;
|
||||||
|
}
|
||||||
command = (command[0] != '!') ? command : command + 1;
|
command = (command[0] != '!') ? command : command + 1;
|
||||||
|
|
||||||
mutex_lock(&trigger_cmd_mutex);
|
mutex_lock(&trigger_cmd_mutex);
|
||||||
|
@ -630,8 +636,14 @@ event_trigger_callback(struct event_command *cmd_ops,
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* separate the trigger from the filter (t:n [if filter]) */
|
/* separate the trigger from the filter (t:n [if filter]) */
|
||||||
if (param && isdigit(param[0]))
|
if (param && isdigit(param[0])) {
|
||||||
trigger = strsep(¶m, " \t");
|
trigger = strsep(¶m, " \t");
|
||||||
|
if (param) {
|
||||||
|
param = skip_spaces(param);
|
||||||
|
if (!*param)
|
||||||
|
param = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
trigger_ops = cmd_ops->get_trigger_ops(cmd, trigger);
|
trigger_ops = cmd_ops->get_trigger_ops(cmd, trigger);
|
||||||
|
|
||||||
|
@ -1368,6 +1380,11 @@ int event_enable_trigger_func(struct event_command *cmd_ops,
|
||||||
trigger = strsep(¶m, " \t");
|
trigger = strsep(¶m, " \t");
|
||||||
if (!trigger)
|
if (!trigger)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
if (param) {
|
||||||
|
param = skip_spaces(param);
|
||||||
|
if (!*param)
|
||||||
|
param = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
system = strsep(&trigger, ":");
|
system = strsep(&trigger, ":");
|
||||||
if (!trigger)
|
if (!trigger)
|
||||||
|
|
Loading…
Reference in New Issue