public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Qi Tang <tpluszz77@gmail.com>,
	Alexei Starovoitov <ast@kernel.org>,
	 Daniel Borkmann <daniel@iogearbox.net>
Cc: Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	 John Fastabend <john.fastabend@gmail.com>,
	Song Liu <song@kernel.org>,
	bpf@vger.kernel.org
Subject: Re: [PATCH] bpf: reject direct access to nullable PTR_TO_BUF pointers
Date: Tue, 31 Mar 2026 10:50:54 -0700	[thread overview]
Message-ID: <9594e5fdeaae8f81edd3b73ff7e263c535d74c7c.camel@gmail.com> (raw)
In-Reply-To: <20260331172720.29938-1-tpluszz77@gmail.com>

On Wed, 2026-04-01 at 01:27 +0800, Qi Tang wrote:
> check_mem_access() matches PTR_TO_BUF via base_type() which strips
> PTR_MAYBE_NULL, allowing direct dereference without a null check.
> 
> Map iterator ctx->key and ctx->value are PTR_TO_BUF | PTR_MAYBE_NULL.
> On stop callbacks these are NULL, causing a kernel NULL dereference.
> 
> Add a type_may_be_null() guard to the PTR_TO_BUF branch, matching the
> existing PTR_TO_BTF_ID pattern.
> 
>   BUG: kernel NULL pointer dereference, address: 0000000000000000
>   Oops: Oops: 0000 [#1] SMP KASAN NOPTI
>   RIP: 0010:bpf_prog_5f0e2be830ac3243_null_deref_iter+0x10/0x25
>   Call Trace:
>    bpf_iter_run_prog+0x1c2/0x2e0
>    __bpf_hash_map_seq_show+0x120/0x180
>    bpf_seq_read+0x29c/0x530
>    vfs_read+0x179/0x930
>    ksys_read+0xef/0x1c0
>    do_syscall_64+0xe0/0x1290
>    entry_SYSCALL_64_after_hwframe+0x76/0x7e
>   Kernel panic - not syncing: Fatal exception
> 
> Fixes: 20b2aff4bc15 ("bpf: Introduce MEM_RDONLY flag")
> Signed-off-by: Qi Tang <tpluszz77@gmail.com>
> ---

Hi Qi Tang,

Could you please add a selftest for this change?

[...]

  reply	other threads:[~2026-03-31 17:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31 17:27 [PATCH] bpf: reject direct access to nullable PTR_TO_BUF pointers Qi Tang
2026-03-31 17:50 ` Eduard Zingerman [this message]
2026-04-01  2:23   ` Qi Tang

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=9594e5fdeaae8f81edd3b73ff7e263c535d74c7c.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=martin.lau@linux.dev \
    --cc=song@kernel.org \
    --cc=tpluszz77@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