From: sashiko-bot@kernel.org
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 1/9] bpf: Support __arena and __arena_nullable kfunc argument suffixes
Date: Mon, 03 Aug 2026 13:19:46 +0000 [thread overview]
Message-ID: <20260803131946.67ECE1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260803125115.2264733-2-memxor@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Valid allocated arena objects at page offset 0 are incorrectly translated to NULL when passed to __arena_nullable kfunc arguments.
--
--- Patch [1]: [PATCH bpf-next v3 1/9] bpf: Support __arena and __arena_nullable kfunc argument suffixes ---
commit d1b161404c5304b1bf05e11ad5b7dc889d1dcee6
Author: Tejun Heo <tj@kernel.org>
bpf: Support __arena and __arena_nullable kfunc argument suffixes
This commit adds support for __arena and __arena_nullable kfunc argument
suffixes, allowing kfuncs to receive directly dereferenceable kernel addresses
for arena pointers. It updates the verifier to distill these into argument
flags for the JIT to retrieve.
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index b274004fccfd9..4c50237f49f13 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
[ ... ]
> @@ -12154,6 +12167,31 @@ static int check_kfunc_args(struct bpf_verifier_env *env, struct bpf_call_arg_me
>
> t = btf_type_skip_modifiers(btf, args[i].type, NULL);
>
> + if (base_type(kf_arg_type) == KF_ARG_PTR_TO_ARENA) {
[Severity: High]
Can a valid allocated arena object at page offset 0 be incorrectly translated
to NULL when passed to an __arena_nullable kfunc argument?
Looking at arena_map_alloc() in kernel/bpf/arena.c, the range tree of free
pages includes page offset 0:
err = range_tree_set(&arena->rt, 0, attr->max_entries);
If a user process mmaps the arena or sets map_extra at an address where the
lower 32 bits are zero (e.g., 0x7f0000000000), a BPF program could allocate
an object that gets offset 0. When passed to an __arena_nullable kfunc
argument, the JIT would see the lower 32 bits as exactly zero.
Since the commit message states that __arena_nullable skips the rebase when
the truncated value (arena offset 0) is zero to preserve NULL, would this
cause the kfunc to incorrectly assume a valid optional argument is absent
and lead to dropped data or logic errors?
> + if (!bpf_jit_supports_arena_args()) {
> + verbose(env, "JIT does not support kfunc %s() with arena pointer arguments\n",
> + func_name);
> + return -ENOTSUPP;
> + }
> + if (!env->prog->aux->arena) {
> + verbose(env,
> + "%s arena pointer requires a program with an associated arena\n",
> + reg_arg_name(env, argno));
> + return -EINVAL;
> + }
> + if (regno < 0) {
> + verbose(env, "%s arena pointer cannot be a stack argument\n",
> + reg_arg_name(env, argno));
> + return -EINVAL;
> + }
> + if (reg->type != PTR_TO_ARENA && reg->type != SCALAR_VALUE) {
> + verbose(env, "%s is not a pointer to arena or scalar\n",
> + reg_arg_name(env, argno));
> + return -EINVAL;
> + }
> + continue;
> + }
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260803125115.2264733-1-memxor@gmail.com?part=1
next prev parent reply other threads:[~2026-08-03 13:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 12:51 [PATCH bpf-next v3 0/9] Add arena argument support to kfuncs and struct_ops Kumar Kartikeya Dwivedi
2026-08-03 12:51 ` [PATCH bpf-next v3 1/9] bpf: Support __arena and __arena_nullable kfunc argument suffixes Kumar Kartikeya Dwivedi
2026-08-03 13:19 ` sashiko-bot [this message]
2026-08-03 12:51 ` [PATCH bpf-next v3 2/9] bpf: Support __arena and __arena_nullable on struct_ops arguments Kumar Kartikeya Dwivedi
2026-08-03 14:19 ` sashiko-bot
2026-08-03 12:51 ` [PATCH bpf-next v3 3/9] bpf, x86: JIT __arena kfunc argument rebasing Kumar Kartikeya Dwivedi
2026-08-03 12:51 ` [PATCH bpf-next v3 4/9] bpf, x86: Convert struct_ops arena arguments in the trampoline Kumar Kartikeya Dwivedi
2026-08-03 12:51 ` [PATCH bpf-next v3 5/9] selftests/bpf: Add kfunc __arena and __arena_nullable argument tests Kumar Kartikeya Dwivedi
2026-08-03 13:35 ` sashiko-bot
2026-08-03 12:51 ` [PATCH bpf-next v3 6/9] selftests/bpf: Add JIT-sequence tests for __arena kfunc arguments Kumar Kartikeya Dwivedi
2026-08-03 13:35 ` sashiko-bot
2026-08-03 12:51 ` [PATCH bpf-next v3 7/9] selftests/bpf: Add struct_ops __arena and __arena_nullable argument tests Kumar Kartikeya Dwivedi
2026-08-03 13:39 ` sashiko-bot
2026-08-03 12:51 ` [PATCH bpf-next v3 8/9] bpf, x86: Fix stack-passed arguments for indirect trampolines Kumar Kartikeya Dwivedi
2026-08-03 13:42 ` sashiko-bot
2026-08-03 12:51 ` [PATCH bpf-next v3 9/9] selftests/bpf: Test stack-passed struct_ops arena arguments 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=20260803131946.67ECE1F00A3D@smtp.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox