]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
tracing: Check pid filtering when creating events
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Fri, 26 Nov 2021 18:35:26 +0000 (13:35 -0500)
committerStefan Bader <stefan.bader@canonical.com>
Thu, 3 Feb 2022 17:57:08 +0000 (18:57 +0100)
BugLink: https://bugs.launchpad.net/bugs/1956380
commit 6cb206508b621a9a0a2c35b60540e399225c8243 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: 3fdaf80f4a836 ("tracing: Implement event pid filtering")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
kernel/trace/trace_events.c

index e31ee325dad16348fe851365d38fd3b95a5b2e6f..4acc77e049e5ff5e404d6eb4d9f96a43e8f6882f 100644 (file)
@@ -2247,12 +2247,19 @@ static struct trace_event_file *
 trace_create_new_event(struct trace_event_call *call,
                       struct trace_array *tr)
 {
+       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));
+
+       if (pid_list)
+               file->flags |= EVENT_FILE_FL_PID_FILTER;
+
        file->event_call = call;
        file->tr = tr;
        atomic_set(&file->sm_ref, 0);