Skip to content

Commit

Permalink
events: Reuse value read using READ_ONCE instead of re-reading it
Browse files Browse the repository at this point in the history
In perf_event_addr_filters_apply, the task associated with
the event (event->ctx->task) is read using READ_ONCE at the beginning
of the function, checked, and then re-read from event->ctx->task,
voiding all guarantees of the checks. Reuse the value that was read by
READ_ONCE to ensure the consistency of the task struct throughout the
function.

Fixes: 375637b ("perf/core: Introduce address range filtering")
Signed-off-by: Baptiste Lepers <baptiste.lepers@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20210906015310.12802-1-baptiste.lepers@gmail.com
  • Loading branch information
Baptiste Lepers authored and Peter Zijlstra committed Sep 15, 2021
1 parent 6880fa6 commit b89a05b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -10193,7 +10193,7 @@ static void perf_event_addr_filters_apply(struct perf_event *event)
return;

if (ifh->nr_file_filters) {
mm = get_task_mm(event->ctx->task);
mm = get_task_mm(task);
if (!mm)
goto restart;

Expand Down

0 comments on commit b89a05b

Please sign in to comment.