[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <795d9f60-73c8-48da-87a4-6336c170b388@amd.com>
Date: Fri, 17 Jan 2025 10:50:26 +0530
From: Ravi Bangoria <ravi.bangoria@....com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: "mingo@...nel.org" <mingo@...nel.org>,
"lucas.demarchi@...el.com" <lucas.demarchi@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"willy@...radead.org" <willy@...radead.org>,
"acme@...nel.org" <acme@...nel.org>,
"namhyung@...nel.org" <namhyung@...nel.org>,
"mark.rutland@....com" <mark.rutland@....com>,
"alexander.shishkin@...ux.intel.com" <alexander.shishkin@...ux.intel.com>,
"jolsa@...nel.org" <jolsa@...nel.org>,
"irogers@...gle.com" <irogers@...gle.com>,
"adrian.hunter@...el.com" <adrian.hunter@...el.com>,
"kan.liang@...ux.intel.com" <kan.liang@...ux.intel.com>,
Ravi Bangoria <ravi.bangoria@....com>
Subject: Re: [PATCH 19/19] perf: Make perf_pmu_unregister() useable
Hi Peter,
>> 4) A race with perf_event_set_bpf_prog(). perf_event_set_bpf_prog() might
>> be in process of setting event->prog, where as perf_pmu_unregister(),
>> which internally calls perf_event_free_bpf_prog(), will clear the
>> event->prog pointer.
>>
>> perf_pmu_unregister() perf_event_set_bpf_prog()
>> ... perf_event_set_bpf_handler()
>> perf_event_free_bpf_prog() event->prog = prog;
>> event->prog = NULL;
>>
>> I've yet to inspect other code paths, so there might be more races.
>
> Weird, that should be serialized by perf_event_ctx_lock(), both
> __pmu_detach_event() and _perf_ioctl() are called under that.
There are multiple code paths leading to perf_event_set_bpf_prog(). The
one starting from _perf_ioctl() is serialized. However, this is not:
__sys_bpf()
link_create()
bpf_perf_link_attach()
perf_event_set_bpf_prog()
perf_event_set_bpf_handler()
event->prog = prog;
Thanks,
Ravi
Powered by blists - more mailing lists