From: sashiko-bot@kernel.org
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 2/9] bpf: Support __arena and __arena_nullable on struct_ops arguments
Date: Mon, 03 Aug 2026 14:19:45 +0000 [thread overview]
Message-ID: <20260803141946.5DB561F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260803125115.2264733-3-memxor@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The `__arena_nullable` BTF parameter suffix is erroneously processed as `__nullable` due to substring matching, breaking `PTR_TO_ARENA` semantics.
- [High] Attaching tracing programs (fentry/fexit) to struct_ops programs with arena arguments causes them to receive 32-bit user-space offsets typed as valid kernel pointers, leading to SMAP violations and kernel panics.
- [Low] Modified multi-line comments do not conform to the required BPF subsystem comment style.
--
--- Patch [2]: [PATCH bpf-next v3 2/9] bpf: Support __arena and __arena_nullable on struct_ops arguments ---
Note: The format of this review has been altered due to system restrictions on
reciting original code. Instead of inline diff quotes, this report provides a
free-form summary of the findings.
commit 0582d11e29a7b343a06709e7d3f0cdcc15655dcc
Author: Tejun Heo <tj@kernel.org>
Subject: bpf: Support __arena and __arena_nullable on struct_ops arguments
This patch adds support for the __arena and __arena_nullable suffixes on
struct_ops arguments. This allows callbacks to declare parameters as arena
pointers, while the kernel caller passes the kernel arena address and the
trampoline handles the conversion.
[Severity: High]
In kernel/bpf/bpf_struct_ops.c within prepare_arg_info(), does the if/else
chain incorrectly prioritize the shorter suffix? Because
btf_param_match_suffix() matches the end of the parameter name, a parameter
ending in __arena_nullable also matches the shorter __nullable suffix.
Since the code checks for the nullable condition first, will this cause
__arena_nullable parameters to be incorrectly typed as PTR_MAYBE_NULL and
PTR_TO_BTF_ID rather than PTR_TO_ARENA? This seems like it could cause the
trampoline to skip the arena pointer conversion, passing a raw kernel
pointer instead, and potentially leading to verifier errors if used with a
non-struct pointer.
[Severity: Low]
This isn't a bug, but in kernel/bpf/bpf_struct_ops.c within
prepare_arg_info(), the modified multi-line comments appear to retain the
older kernel comment style where text follows the opening delimiter on the
same line.
Does the BPF subsystem require multi-line comments to have the opening
delimiter on its own line, even when modifying existing comments in a file
that previously used the old style?
[Severity: High]
In kernel/bpf/trampoline.c within bpf_trampoline_update(), does the
defensive check evaluate the wrong program's context arguments? The code
appears to check the attached tracing program (fentry/fexit) for arena
arguments rather than the target struct_ops program.
Since tracing programs do not have their ctx_arg_info initialized, could
this allow them to successfully attach to struct_ops programs that have
arena arguments?
If so, during verification in kernel/bpf/btf.c at btf_ctx_access(), the
tracing program's context argument would be typed as a standard
PTR_TO_BTF_ID because its ctx_arg_info_size is zero. At runtime, the
struct_ops trampoline would convert the kernel pointer to a 32-bit arena
offset, which the tracing program would receive and potentially dereference
as a standard kernel pointer. Could this sequence lead to SMAP violations
and kernel panics?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260803125115.2264733-1-memxor@gmail.com?part=2
next prev parent reply other threads:[~2026-08-03 14:19 UTC|newest]
Thread overview: 37+ 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
2026-08-04 17:42 ` Amery Hung
2026-08-05 15:53 ` Kumar Kartikeya Dwivedi
2026-08-05 17:07 ` Amery Hung
2026-08-05 17:16 ` Kumar Kartikeya Dwivedi
2026-08-05 15:55 ` Kumar Kartikeya Dwivedi
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 [this message]
2026-08-04 23:55 ` Eduard Zingerman
2026-08-05 5:14 ` Eduard Zingerman
2026-08-05 17:31 ` Amery Hung
2026-08-05 17:36 ` Kumar Kartikeya Dwivedi
2026-08-03 12:51 ` [PATCH bpf-next v3 3/9] bpf, x86: JIT __arena kfunc argument rebasing Kumar Kartikeya Dwivedi
2026-08-05 0:40 ` Eduard Zingerman
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-04 20:01 ` Eduard Zingerman
2026-08-04 20:14 ` Kumar Kartikeya Dwivedi
2026-08-04 20:24 ` Eduard Zingerman
2026-08-04 20:26 ` Eduard Zingerman
2026-08-04 20:28 ` Kumar Kartikeya Dwivedi
2026-08-04 20:33 ` Eduard Zingerman
2026-08-04 20:36 ` Eduard Zingerman
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-05 5:43 ` Eduard Zingerman
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-05 6:52 ` Eduard Zingerman
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-05 8:00 ` Eduard Zingerman
2026-08-03 12:51 ` [PATCH bpf-next v3 9/9] selftests/bpf: Test stack-passed struct_ops arena arguments Kumar Kartikeya Dwivedi
2026-08-05 8:00 ` Eduard Zingerman
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=20260803141946.5DB561F000E9@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 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.