]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
events: Reuse value read using READ_ONCE instead of re-reading it
authorBaptiste Lepers <baptiste.lepers@gmail.com>
Mon, 6 Sep 2021 01:53:10 +0000 (11:53 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Sep 2021 09:45:33 +0000 (11:45 +0200)
commit b89a05b21f46150ac10a962aa50109250b56b03b upstream.

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: 375637bc52495 ("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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/events/core.c

index 1aa094c5dedb4179f2253ff9d2669a79b8baa01d..236e7900e3fca7640b42b2fead55ada5ca20a99e 100644 (file)
@@ -8435,7 +8435,7 @@ static void perf_event_addr_filters_apply(struct perf_event *event)
        if (!ifh->nr_file_filters)
                return;
 
-       mm = get_task_mm(event->ctx->task);
+       mm = get_task_mm(task);
        if (!mm)
                goto restart;