Skip to content

Commit

Permalink
tracing: Fix pid filtering when triggers are attached
Browse files Browse the repository at this point in the history
If a event is filtered by pid and a trigger that requires processing of
the event to happen is a attached to the event, the discard portion does
not take the pid filtering into account, and the event will then be
recorded when it should not have been.

Cc: [email protected]
Fixes: 3fdaf80 ("tracing: Implement event pid filtering")
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
  • Loading branch information
rostedt committed Nov 26, 2021
1 parent 6cb2065 commit a55f224
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions kernel/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -1366,14 +1366,26 @@ __event_trigger_test_discard(struct trace_event_file *file,
if (eflags & EVENT_FILE_FL_TRIGGER_COND)
*tt = event_triggers_call(file, buffer, entry, event);

if (test_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &file->flags) ||
(unlikely(file->flags & EVENT_FILE_FL_FILTERED) &&
!filter_match_preds(file->filter, entry))) {
__trace_event_discard_commit(buffer, event);
return true;
}
if (likely(!(file->flags & (EVENT_FILE_FL_SOFT_DISABLED |
EVENT_FILE_FL_FILTERED |
EVENT_FILE_FL_PID_FILTER))))
return false;

if (file->flags & EVENT_FILE_FL_SOFT_DISABLED)
goto discard;

if (file->flags & EVENT_FILE_FL_FILTERED &&
!filter_match_preds(file->filter, entry))
goto discard;

if ((file->flags & EVENT_FILE_FL_PID_FILTER) &&
trace_event_ignore_this_pid(file))
goto discard;

return false;
discard:
__trace_event_discard_commit(buffer, event);
return true;
}

/**
Expand Down

0 comments on commit a55f224

Please sign in to comment.