Skip to content

Commit

Permalink
tracing: Check pid filtering when creating events
Browse files Browse the repository at this point in the history
commit 6cb2065 upstream.

When pid filtering is activated in an instance, all of the events trace
files for that instance has the PID_FILTER flag set. This determines
whether or not pid filtering needs to be done on the event, otherwise the
event is executed as normal.

If pid filtering is enabled when an event is created (via a dynamic event
or modules), its flag is not updated to reflect the current state, and the
events are not filtered properly.

Cc: stable@vger.kernel.org
Fixes: 3fdaf80 ("tracing: Implement event pid filtering")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
rostedt authored and gregkh committed Dec 1, 2021
1 parent 4fd0ad0 commit 406f2d5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions kernel/trace/trace_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -2462,12 +2462,22 @@ static struct trace_event_file *
trace_create_new_event(struct trace_event_call *call,
struct trace_array *tr)
{
struct trace_pid_list *no_pid_list;
struct trace_pid_list *pid_list;
struct trace_event_file *file;

file = kmem_cache_alloc(file_cachep, GFP_TRACE);
if (!file)
return NULL;

pid_list = rcu_dereference_protected(tr->filtered_pids,
lockdep_is_held(&event_mutex));
no_pid_list = rcu_dereference_protected(tr->filtered_no_pids,
lockdep_is_held(&event_mutex));

if (pid_list || no_pid_list)
file->flags |= EVENT_FILE_FL_PID_FILTER;

file->event_call = call;
file->tr = tr;
atomic_set(&file->sm_ref, 0);
Expand Down

0 comments on commit 406f2d5

Please sign in to comment.