Re: [PATCH] perf/bpf: Fix lockless access to parent_event->prog in perf_event_alloc()
From: Deepanshu Kartikey
Date: Mon Aug 24 2026 - 21:39:54 EST
On Sat, Aug 22, 2026 at 12:04 AM Andrii Nakryiko
<andrii.nakryiko@xxxxxxxxx> wrote:
>
> exposing this mutex like that is definitely a smell.
>
> AI tells me that this perf event inheritance case can happen for
> non-tracing (i.e., BPF_PROG_TYPE_PERF_EVENT) events, which are
> attached while holding perf_event_ctx_lock, not the bpf_event_mutex
> (this one is held for tracepoint/kprobe/uprobe programs).
>
> Please validate and adjust the fix.
>
Thank you! You are correct.
perf_event_set_bpf_handler() is called
via two paths:
1. perf_event_set_bpf_prog() with ctx_lock
2. _perf_ioctl() with no lock
I will investigate the correct fix.
Thanks
Deepanshu