[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250117083657.GL8362@noisy.programming.kicks-ass.net>
Date: Fri, 17 Jan 2025 09:36:57 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Ravi Bangoria <ravi.bangoria@....com>
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>
Subject: Re: [PATCH 19/19] perf: Make perf_pmu_unregister() useable
On Fri, Jan 17, 2025 at 10:50:26AM +0530, Ravi Bangoria wrote:
> 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;
>
Urgh yeah, that's broken. Damn bpf stuff :-/
Powered by blists - more mailing lists