From: JP Kobryn <inwardvessel@gmail.com>
To: Luigi Rizzo <lrizzo@google.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
Naveen N Rao <naveen@kernel.org>,
Luigi Rizzo <rizzo.unipi@gmail.com>,
"David S . Miller" <davem@davemloft.net>
Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kprobes: Fix NULL pointer dereference in unregister_kretprobes()
Date: Wed, 5 Aug 2026 13:25:35 -0700 [thread overview]
Message-ID: <b0d9df6c-c408-4482-b221-34093c110580@gmail.com> (raw)
In-Reply-To: <20260805161221.2428623-1-lrizzo@google.com>
On 8/5/2026 9:12 AM, Luigi Rizzo wrote:
> In unregister_kretprobes(), rps[i]->rph can be NULL e.g. when called
> after kretprobe failed registration. Under !CONFIG_KRETPROBE_ON_RETHOOK,
> the unconditional access to rps[i]->rph->rp, causes a kernel panic due
> to NULL pointer dereference.
>
> Add a NULL check for rps[i]->rph before invoking rcu_assign_pointer().
>
> Fixes: d839a656d0f3 ("kprobes: consistent rcu api usage for kretprobe holder")
The bug was not introduced in this commit. It goes further back to:
d741bf41d7c7 ("kprobes: Remove kretprobe hash")
> Signed-off-by: Luigi Rizzo <lrizzo@google.com>
> ---
> kernel/kprobes.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index bfc89083daa93..5dd4786c455de 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -2359,7 +2359,8 @@ void unregister_kretprobes(struct kretprobe **rps, int num)
> #ifdef CONFIG_KRETPROBE_ON_RETHOOK
> rethook_free(rps[i]->rh);
> #else
> - rcu_assign_pointer(rps[i]->rph->rp, NULL);
> + if (rps[i]->rph)
> + rcu_assign_pointer(rps[i]->rph->rp, NULL);
> #endif
> }
>
next prev parent reply other threads:[~2026-08-05 20:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 16:12 [PATCH] kprobes: Fix NULL pointer dereference in unregister_kretprobes() Luigi Rizzo
2026-08-05 18:40 ` Bradley Morgan
2026-08-05 20:25 ` JP Kobryn [this message]
2026-08-06 0:02 ` Masami Hiramatsu
2026-08-06 7:23 ` Luigi Rizzo
2026-08-06 13:41 ` Masami Hiramatsu
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=b0d9df6c-c408-4482-b221-34093c110580@gmail.com \
--to=inwardvessel@gmail.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=lrizzo@google.com \
--cc=mhiramat@kernel.org \
--cc=naveen@kernel.org \
--cc=rizzo.unipi@gmail.com \
/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