Commit d8a30f20 authored by Steven Rostedt (Red Hat)'s avatar Steven Rostedt (Red Hat) Committed by Steven Rostedt

tracing: Fix rcu handling of event_trigger_data filter field

The filter field of the event_trigger_data structure is protected under
RCU sched locks. It was not annotated as such, and after doing so,
sparse pointed out several locations that required fix ups.
Reported-by: default avatarkbuild test robot <fengguang.wu@intel.com>
Tested-by: default avatarTom Zanussi <tom.zanussi@linux.intel.com>
Acked-by: default avatarTom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 098c879e
...@@ -1057,7 +1057,7 @@ struct event_trigger_data { ...@@ -1057,7 +1057,7 @@ struct event_trigger_data {
int ref; int ref;
struct event_trigger_ops *ops; struct event_trigger_ops *ops;
struct event_command *cmd_ops; struct event_command *cmd_ops;
struct event_filter *filter; struct event_filter __rcu *filter;
char *filter_str; char *filter_str;
void *private_data; void *private_data;
struct list_head list; struct list_head list;
......
...@@ -67,6 +67,7 @@ event_triggers_call(struct ftrace_event_file *file, void *rec) ...@@ -67,6 +67,7 @@ event_triggers_call(struct ftrace_event_file *file, void *rec)
{ {
struct event_trigger_data *data; struct event_trigger_data *data;
enum event_trigger_type tt = ETT_NONE; enum event_trigger_type tt = ETT_NONE;
struct event_filter *filter;
if (list_empty(&file->triggers)) if (list_empty(&file->triggers))
return tt; return tt;
...@@ -76,7 +77,8 @@ event_triggers_call(struct ftrace_event_file *file, void *rec) ...@@ -76,7 +77,8 @@ event_triggers_call(struct ftrace_event_file *file, void *rec)
data->ops->func(data); data->ops->func(data);
continue; continue;
} }
if (data->filter && !filter_match_preds(data->filter, rec)) filter = rcu_dereference(data->filter);
if (filter && !filter_match_preds(filter, rec))
continue; continue;
if (data->cmd_ops->post_trigger) { if (data->cmd_ops->post_trigger) {
tt |= data->cmd_ops->trigger_type; tt |= data->cmd_ops->trigger_type;
...@@ -703,7 +705,7 @@ static int set_trigger_filter(char *filter_str, ...@@ -703,7 +705,7 @@ static int set_trigger_filter(char *filter_str,
if (ret) if (ret)
goto out; goto out;
assign: assign:
tmp = data->filter; tmp = rcu_access_pointer(data->filter);
rcu_assign_pointer(data->filter, filter); rcu_assign_pointer(data->filter, filter);
...@@ -719,7 +721,7 @@ static int set_trigger_filter(char *filter_str, ...@@ -719,7 +721,7 @@ static int set_trigger_filter(char *filter_str,
if (filter_str) { if (filter_str) {
data->filter_str = kstrdup(filter_str, GFP_KERNEL); data->filter_str = kstrdup(filter_str, GFP_KERNEL);
if (!data->filter_str) { if (!data->filter_str) {
free_event_filter(data->filter); free_event_filter(rcu_access_pointer(data->filter));
data->filter = NULL; data->filter = NULL;
ret = -ENOMEM; ret = -ENOMEM;
} }
......
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