From: Steven Rostedt <rostedt@goodmis.org>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Shijia Hu <hushijia1@uniontech.com>,
naveen@kernel.org, davem@davemloft.net, ananth@in.ibm.com,
akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] kprobes: Remove dead child probes from aggrprobe list on module unload
Date: Wed, 29 Apr 2026 11:56:45 -0400 [thread overview]
Message-ID: <20260429115645.793f15ea@gandalf.local.home> (raw)
In-Reply-To: <20260429174053.b66f3a0032408f544128afd4@kernel.org>
On Wed, 29 Apr 2026 17:40:53 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
> Shijia Hu <hushijia1@uniontech.com> wrote:
>
> > When a kernel module that registered kprobes is unloaded without calling
> > unregister_kprobe(), kprobes_module_callback() calls kill_kprobe() to
> > mark the probe(s) GONE. If the probe is an aggrprobe, kill_kprobe()
> > also marks all child probes GONE, but it does not remove them from
> > the aggrprobe's list.
>
> That sounds like a bug in the module.
Agreed.
>
> >
> > The problem is that child probes whose struct kprobe resides in the
> > unloading module's memory are freed along with the module, yet they
> > remain on the aggrprobe's list. Later, when another caller registers
> > a kprobe at the same address, __get_valid_kprobe() walks that list
> > and dereferences the freed child probe, causing a use-after-free.
> >
> > Reproduction steps:
> >
> > 1) Load module A which registers two kprobes on the same kernel
> > function address (e.g., do_nanosleep), causing them to be
> > aggregated under one aggrprobe.
> >
> > 2) Unload module A without calling unregister_kprobe().
> > Module A's memory is freed, but its two child probes remain
> > on the aggrprobe's list as dangling pointers.
>
> Would you mean "load a buggy kernel module and unload it, the kernel cause
> use-after-free."? for example:
>
> ----
> struct kprobe my_probe = {...};
>
> init_module() {
> register_kprobe(&my_probe);
> }
> exit_module() {
> /* do nothing */
> }
> ----
>
> Yes, this cause UAF because that module has a bug. Please call
> unregister_kprobe().
Yes, this is one of those...
Patient: Doctor it hurts me when I do this
Doctor: Then don't do that
... reports.
No, the kernel isn't responsible for fixing buggy modules.
-- Steve
next prev parent reply other threads:[~2026-04-29 15:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 3:29 [PATCH] kprobes: Remove dead child probes from aggrprobe list on module unload Shijia Hu
2026-04-29 8:40 ` Masami Hiramatsu
2026-04-29 15:56 ` Steven Rostedt [this message]
2026-04-30 1:39 ` Shijia Hu
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=20260429115645.793f15ea@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=ananth@in.ibm.com \
--cc=davem@davemloft.net \
--cc=hushijia1@uniontech.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=naveen@kernel.org \
/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