Skip to content

Commit 8ec8405

Browse files
committed
tracing: Add rcu dereference annotation for test func that touches filter->prog
A boot up test function update_pred_fn() dereferences filter->prog without the proper rcu annotation. To do this, we must also take the event_mutex first. Normally, this isn't needed because this test function can not race with other use cases that touch the event filters (it is disabled if any events are enabled). Reported-by: kbuild test robot <[email protected]> Fixes: 8076559 ("tracing: Rewrite filter logic to be simpler and faster") Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 1f3b0fa commit 8ec8405

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

kernel/trace/trace_events_filter.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2155,7 +2155,8 @@ static int test_pred_visited_fn(struct filter_pred *pred, void *event)
21552155

21562156
static void update_pred_fn(struct event_filter *filter, char *fields)
21572157
{
2158-
struct prog_entry *prog = filter->prog;
2158+
struct prog_entry *prog = rcu_dereference_protected(filter->prog,
2159+
lockdep_is_held(&event_mutex));
21592160
int i;
21602161

21612162
for (i = 0; prog[i].pred; i++) {
@@ -2197,6 +2198,8 @@ static __init int ftrace_test_event_filter(void)
21972198
break;
21982199
}
21992200

2201+
/* Needed to dereference filter->prog */
2202+
mutex_lock(&event_mutex);
22002203
/*
22012204
* The preemption disabling is not really needed for self
22022205
* tests, but the rcu dereference will complain without it.
@@ -2209,6 +2212,8 @@ static __init int ftrace_test_event_filter(void)
22092212
err = filter_match_preds(filter, &d->rec);
22102213
preempt_enable();
22112214

2215+
mutex_unlock(&event_mutex);
2216+
22122217
__free_filter(filter);
22132218

22142219
if (test_pred_visited) {

0 commit comments

Comments
 (0)