Re: [GIT PULL] tracing: Two event pid filtering bug fixes

From: Steven Rostedt
Date: Sat Nov 27 2021 - 16:45:56 EST


On Sat, 27 Nov 2021 13:28:22 -0500
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> + struct trace_pid_list *no_pid_list;
> + struct trace_pid_list *pid_list;
> struct trace_event_file *file;
> + unsigned int first;
>
> 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 (!trace_pid_list_first(pid_list, &first) ||
> + !trace_pid_list_first(pid_list, &first))
> + file->flags |= EVENT_FILE_FL_PID_FILTER;

And of course since I only tested "trace only this pid" case, and not
the "trace everything but this pid" case, the above has a bug (which
the ktest bot just told me about), and my tests missed it.

That should have been:

if (!trace_pid_list_first(pid_list, &first) ||
!trace_pid_list_first(no_pid_list, &first))

I'll fix it, run it through my tests, and post another pull request :-/.

/me needs to add that case to his tests, even though it's extremely
rare (I never use it). Which is exactly why I should have a test for it!

-- Steve