All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Nuoqi Gui" <gnq25@mails.tsinghua.edu.cn>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: "Martin KaFai Lau" <martin.lau@linux.dev>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"Jiri Olsa" <jolsa@kernel.org>, "Shuah Khan" <shuah@kernel.org>,
	<bpf@vger.kernel.org>, <linux-kselftest@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH bpf 1/2] bpf: Mark bpf_get_kmem_cache() as nullable
Date: Sat, 20 Jun 2026 10:47:26 -0700	[thread overview]
Message-ID: <DJE2CTA52OO1.1M9LF27NDWK2V@gmail.com> (raw)
In-Reply-To: <20260620-f01-16-kmem-cache-ret-null-v1-1-c146154a2816@mails.tsinghua.edu.cn>

On Sat Jun 20, 2026 at 8:47 AM PDT, Nuoqi Gui wrote:
> bpf_get_kmem_cache() returns NULL when virt_addr_valid() rejects the
> address or when virt_to_slab() does not find a slab. The verifier uses
> KF_RET_NULL to add PTR_MAYBE_NULL to kfunc return registers, but the
> registration currently lacks that flag.
>
> Add KF_RET_NULL so callers have to prove that the returned kmem_cache
> pointer is non-NULL before dereferencing fields.
>
> Fixes: a992d7a397912 ("mm/bpf: Add bpf_get_kmem_cache() kfunc")
> Signed-off-by: Nuoqi Gui <gnq25@mails.tsinghua.edu.cn>
> ---
>  kernel/bpf/helpers.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> index b5314c9fed3cf..57a6ab72ae3cc 100644
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c
> @@ -4817,7 +4817,7 @@ BTF_ID_FLAGS(func, bpf_iter_bits_next, KF_ITER_NEXT | KF_RET_NULL)
>  BTF_ID_FLAGS(func, bpf_iter_bits_destroy, KF_ITER_DESTROY)
>  BTF_ID_FLAGS(func, bpf_copy_from_user_str, KF_SLEEPABLE)
>  BTF_ID_FLAGS(func, bpf_copy_from_user_task_str, KF_SLEEPABLE)
> -BTF_ID_FLAGS(func, bpf_get_kmem_cache)
> +BTF_ID_FLAGS(func, bpf_get_kmem_cache, KF_RET_NULL)

This is wrong. Nothing to fix.
It works as designed.
Instead of sending broken patches do your home work.
You're saying commit a992d7a397912 is buggy. Read its commit log, selftest
and the email thread and see why this patch is wrong.

Such poor quality patches undermine your other legitimate fixes.
You have to step up in quality.

pw-bot: cr


  reply	other threads:[~2026-06-20 17:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-20 15:47 [PATCH bpf 0/2] bpf: Mark bpf_get_kmem_cache() as nullable Nuoqi Gui
2026-06-20 15:47 ` [PATCH bpf 1/2] " Nuoqi Gui
2026-06-20 17:47   ` Alexei Starovoitov [this message]
2026-06-20 15:47 ` [PATCH bpf 2/2] selftests/bpf: Cover bpf_get_kmem_cache() null return Nuoqi Gui

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=DJE2CTA52OO1.1M9LF27NDWK2V@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=gnq25@mails.tsinghua.edu.cn \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=shuah@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.