Re: [PATCH] perf/bpf: Fix data race in __perf_event_overflow

From: bot+bpf-ci

Date: Tue Aug 11 2026 - 21:06:30 EST


> commit ffa161d3558e4937793a0c3e98e19e4b22e58bd9
> Author: Deepanshu Kartikey <kartikey406@xxxxxxxxx>
> Date: Wed Aug 12 05:23:31 2026 +0530
>
> perf/bpf: Fix data race in __perf_event_overflow
>
> perf_event_detach_bpf_prog() writes event->prog = NULL
> under bpf_event_mutex, while __perf_event_overflow() reads
> event->prog concurrently without any lock protection. This
> causes a data race detected by KCSAN.
>
> __perf_event_overflow() can be called from interrupt/NMI
> context, so it cannot acquire bpf_event_mutex. Fix the race
> by using WRITE_ONCE() in perf_event_detach_bpf_prog() and
> READ_ONCE() in __perf_event_overflow(). Also store the result
> of READ_ONCE() in a local variable to avoid reading event->prog
> twice which could result in a NULL pointer dereference if the
> pointer becomes NULL between the two reads.
>
> Reported-by: syzbot+651d2774bd1d8395595f@xxxxxxxxxxxxxxxxxxxxxxxxx
> Closes: https://syzkaller.appspot.com/bug?extid=651d2774bd1d8395595f
> Fixes: f11f10bfa1ca ("perf/bpf: Call BPF handler directly, not through overflow machinery")
> Signed-off-by: Deepanshu Kartikey <kartikey406@xxxxxxxxx>
> Reported-by: syzbot+651d2774bd1d8395595f@xxxxxxxxxxxxxxxxxxxxxxxxx
> Signed-off-by: Deepanshu Kartikey <kartikey406@xxxxxxxxx>

The trailer block contains duplicate tags: both Reported-by: and
Signed-off-by: appear twice. Also, the second Reported-by: is placed
after the first Signed-off-by:, which breaks the conventional trailer
ordering (Reported-by/Closes/Fixes should come before Signed-off-by).

Should the duplicates be collapsed to one of each, in proper trailer order?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/31550171807