From: sashiko-bot@kernel.org
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v1 02/10] bpf: Recognize __nullable on pointer members of kernel structs
Date: Mon, 12 Oct 2026 13:54:16 +0000 [thread overview]
Message-ID: <sashiko-outbox-168221@kernel.org> (raw)
In-Reply-To: <20261012133711.4030594-3-memxor@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] bpf: MEM_RCU map pointers bypass PROBE_MEM and NULL checks
--
commit cd9a005edc33a27f4ea8950cfa7c36fe9d72a985
Author: Kumar Kartikeya Dwivedi <memxor@gmail.com>
bpf: Recognize __nullable on pointer members of kernel structs
This patch teaches the BPF verifier to recognize the __nullable BTF type tag
on pointer members of kernel structs, assigning them the PTR_MAYBE_NULL flag.
The flag is kept on trusted and RCU pointers, forcing BPF programs to
explicitly check them before use.
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 2f190abe34489..70fd44a6e1c56 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
[ ... ]
> @@ -6785,6 +6792,8 @@ static int check_ptr_to_map_access(struct bpf_verifier_env *env,
> ret = btf_struct_access(&env->log, &map_reg, off, size, atype, &btf_id, &flag, NULL);
> if (ret < 0)
> return ret;
> + /* Nothing walked from a map is trusted, a __nullable member changes nothing. */
> + flag &= ~PTR_MAYBE_NULL;
^^^^^^^^^^^^^^^^^^^^^^^^
[Severity: High]
Does stripping PTR_MAYBE_NULL here allow MEM_RCU map pointers to bypass both
PROBE_MEM and NULL checks?
When a CAP_PERFMON BPF program reads an __rcu-tagged pointer field from a map
structure (e.g., trie->root in struct lpm_trie), btf_struct_access() evaluates
the tag and returns MEM_RCU in flag.
If we explicitly clear PTR_MAYBE_NULL here without clearing MEM_RCU or adding
PTR_UNTRUSTED, the verifier assigns PTR_TO_BTF_ID | MEM_RCU to the destination
register.
Since bpf_may_fault_on_deref(PTR_TO_BTF_ID | MEM_RCU) evaluates to false (as it
expects exactly PTR_TO_BTF_ID or the PTR_UNTRUSTED flag), the load is not
rewritten to BPF_PROBE_MEM. Because PTR_MAYBE_NULL was stripped, the verifier
will permit the dereference without a NULL check.
At runtime, reading from a NULL pointer (like a NULL trie->root) would then
perform a bare memory load and crash the kernel. Does this active stripping
prevent the new __nullable tag from protecting these vulnerable pointers?
>
> if (value_regno >= 0) {
> ret = mark_btf_ld_reg(env, regs, value_regno, ret, btf_vmlinux, btf_id, flag);
> if (ret < 0)
> return ret;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261012133711.4030594-1-memxor@gmail.com?part=2
next prev parent reply other threads:[~2026-10-12 13:54 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 13:36 [PATCH bpf-next v1 00/10] Fix some arena paper cuts Kumar Kartikeya Dwivedi
2026-10-12 13:36 ` [PATCH bpf-next v1 01/10] compiler_types: Add __arena and __nullable BTF type tag qualifiers Kumar Kartikeya Dwivedi
2026-10-12 13:36 ` [PATCH bpf-next v1 02/10] bpf: Recognize __nullable on pointer members of kernel structs Kumar Kartikeya Dwivedi
2026-10-12 13:54 ` sashiko-bot [this message]
2026-10-12 13:37 ` [PATCH bpf-next v1 03/10] bpf: Turn loads of __arena pointer members into arena pointers Kumar Kartikeya Dwivedi
2026-10-12 14:00 ` sashiko-bot
2026-10-12 14:27 ` bot+bpf-ci
2026-10-12 13:37 ` [PATCH bpf-next v1 04/10] selftests/bpf: Test __nullable pointer members Kumar Kartikeya Dwivedi
2026-10-12 14:27 ` bot+bpf-ci
2026-10-12 13:37 ` [PATCH bpf-next v1 05/10] selftests/bpf: Test __arena " Kumar Kartikeya Dwivedi
2026-10-12 14:27 ` bot+bpf-ci
2026-10-12 13:37 ` [PATCH bpf-next v1 06/10] libbpf: Bind the arena of an object to every program in it Kumar Kartikeya Dwivedi
2026-10-12 14:27 ` bot+bpf-ci
2026-10-12 13:37 ` [PATCH bpf-next v1 07/10] selftests/bpf: Test arena binding by libbpf Kumar Kartikeya Dwivedi
2026-10-12 13:44 ` sashiko-bot
2026-10-12 14:27 ` bot+bpf-ci
2026-10-12 13:37 ` [PATCH bpf-next v1 08/10] bpf: Set up the arena base only in functions that use it Kumar Kartikeya Dwivedi
2026-10-12 14:27 ` bot+bpf-ci
2026-10-12 13:37 ` [PATCH bpf-next v1 09/10] libbpf: Render the arena type tag with its address space Kumar Kartikeya Dwivedi
2026-10-12 13:37 ` [PATCH bpf-next v1 10/10] selftests/bpf: Test the address space rendering of the arena type tag Kumar Kartikeya Dwivedi
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=sashiko-outbox-168221@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=memxor@gmail.com \
--cc=sashiko-reviews@lists.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.