From: "Chris Mason" <mason@kernel.org>
To: "Jiri Olsa" <olsajiri@gmail.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
andrii@kernel.org, song@kernel.org, eddyz87@gmail.com,
memxor@gmail.com, martin.lau@linux.dev, yonghong.song@linux.dev,
emil@etsalapatis.com, ihor.solodrai@linux.dev,
rostedt@goodmis.org, mhiramat@kernel.org,
mathieu.desnoyers@efficios.com, mjambigi@linux.ibm.com,
petr.pavlu@suse.com, linux-trace-kernel@vger.kernel.org,
linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf 2/2] bpf: Reject kprobe_multi links on coming modules
Date: Fri, 04 Dec 2026 10:11:35 -0500 [thread overview]
Message-ID: <1796389320.2.31741.0@kernel.org> (raw)
In-Reply-To: <axKQe6swZjR5d65A@krava>
On Fri, 4 Dec 2026 11:05:47 +0100, Jiri Olsa wrote:
> On Thu, Dec 03, 2026 at 03:26:17PM -0500, Chris Mason wrote:
>> bpf_kprobe_multi_link_release() hits a use-after-free on struct module
>> if a probed module fails to load.
>>
>> get_modules_for_addrs() pins each probed module with try_module_get(),
>> which also succeeds in MODULE_STATE_COMING. But the error paths of
>> load_module() and do_init_module() free the module without checking
>> refcnt:
[ ... ]
>> The fix used here is to pin a module only once it is live, as
>> btf_try_get_module() does.
>
> I wonder this is a problem in other places as well, like in
> trace_event_try_get_ref and possibly other places
Yeah, trace_event_try_get_ref() has the same bug, and perf events, triggers,
function probes and eprobes all use it. I had scanned my pending queue
just for bpf, and this one missed the cut. Thanks for flagging:
https://lore.kernel.org/all/20261204130200.15208-1-mason@kernel.org/
From the code, it looks like register_kprobe(), validate_probe_symbol() and
trace_fprobe_create_internal() have similar issues. They drop their
reference before they return, and Mahanta's patch handles things:
https://lore.kernel.org/all/20261204104104.1711861-1-mjambigi@linux.ibm.com/
-chris
next prev parent reply other threads:[~2026-12-04 15:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 20:26 [PATCH bpf 0/2] bpf: don't attach links to modules that are still loading Chris Mason
2026-12-03 20:26 ` [PATCH bpf 1/2] bpf: Reject raw tracepoint links on coming modules Chris Mason
2026-12-03 20:26 ` [PATCH bpf 2/2] bpf: Reject kprobe_multi " Chris Mason
2026-12-04 10:05 ` Jiri Olsa
2026-12-04 15:11 ` Chris Mason [this message]
2026-12-04 2:30 ` [PATCH bpf 0/2] bpf: don't attach links to modules that are still loading patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1796389320.2.31741.0@kernel.org \
--to=mason@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mathieu.desnoyers@efficios.com \
--cc=memxor@gmail.com \
--cc=mhiramat@kernel.org \
--cc=mjambigi@linux.ibm.com \
--cc=olsajiri@gmail.com \
--cc=petr.pavlu@suse.com \
--cc=rostedt@goodmis.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox