The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Luigi Rizzo <lrizzo@google.com>
Cc: Naveen N Rao <naveen@kernel.org>,
	Luigi Rizzo <rizzo.unipi@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	JP Kobryn <inwardvessel@gmail.com>,
	linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kprobes: Fix NULL pointer dereference in unregister_kretprobes()
Date: Thu, 6 Aug 2026 22:41:25 +0900	[thread overview]
Message-ID: <20260806224125.6c1048fed96cac11bfb31233@kernel.org> (raw)
In-Reply-To: <CAMOZA0+4dE0N3J35pTVTBgvFzP2a-b47Z_LZYwKNwej5jUx0zg@mail.gmail.com>

On Thu, 6 Aug 2026 09:23:29 +0200
Luigi Rizzo <lrizzo@google.com> wrote:

> On Thu, Aug 6, 2026 at 2:02 AM Masami Hiramatsu <mhiramat@kernel.org> wrote:
> >
> > On Wed,  5 Aug 2026 16:12:21 +0000
> > Luigi Rizzo <lrizzo@google.com> 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.
> >
> > This is not a bug, since if register_kretprobe(rp) fails, rp must NOT be
> > passed to unregister_kretprobe(rp). Or, do you find any cases where
> > register_kretprobe() fails, preventing proper cleanup, and requiring
> > unregister_kretprobe()? If so, we have to fix that case.
> 
> Masami, you are right, the kernel tree does not call unregister_kretprobes()
> on a failed registration. I was confused by the unregister_kretprobes(rps, i);
> call in the cleanup in register_kretprobes(), but the failed entry i is
> not unregistered).

Yes, in that case rps[i] is not unregistered ;)

> 
> So aside from protective coding (but where would one stop ?
> null rps, null rps[i], ... ), there is no need for this patch.

OK, Thanks for the confirmation!

Thanks,


> 
> thanks for the feedback
> Luigi


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

      reply	other threads:[~2026-08-06 13:41 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
2026-08-06  0:02 ` Masami Hiramatsu
2026-08-06  7:23   ` Luigi Rizzo
2026-08-06 13:41     ` Masami Hiramatsu [this message]

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=20260806224125.6c1048fed96cac11bfb31233@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=davem@davemloft.net \
    --cc=inwardvessel@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=lrizzo@google.com \
    --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