From: sashiko-bot@kernel.org
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v4 05/13] bpf: Support __arena and __arena__nullable on struct_ops arguments
Date: Wed, 05 Aug 2026 21:18:50 +0000 [thread overview]
Message-ID: <20260805211850.CBFAF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805210427.3218326-6-memxor@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Extension (`freplace`) and tracing (`fentry`/`fexit`) programs attached to `struct_ops` programs with `__arena` arguments bypass type safety, treating user-controlled 32-bit arena offsets as trusted kernel pointers (`PTR_TO_BTF_ID`).
--
--- Patch [5]: [PATCH bpf-next v4 05/13] bpf: Support __arena and __arena__nullable on struct_ops arguments ---
(Note: The formatting of this report is altered due to system recitation restrictions. I am providing a free-form summary of the findings rather than quoting the original code inline.)
commit fe44e46765df675218e6d1c19ad3b275b47f1966
Author: Tejun Heo <tj@kernel.org>
Subject: bpf: Support __arena and __arena__nullable on struct_ops arguments
This patch adds support for __arena and __arena__nullable suffixes on BPF
struct_ops arguments. It allows passing arena pointers directly to struct_ops
callbacks by converting kernel addresses to arena offsets in the trampoline
context array.
[Severity: Critical]
Does this allow extension (freplace) and tracing (fentry/fexit) programs to
bypass type safety when attaching to struct_ops programs that use __arena
arguments?
In kernel/bpf/btf.c:btf_ctx_access(), the verifier iterates over
prog->aux->ctx_arg_info_size to enforce PTR_TO_ARENA. However, for extension
and tracing programs, ctx_arg_info_size is 0. This causes the verifier to skip
the arena type check and fall through, incorrectly typing the argument as a
trusted kernel pointer (PTR_TO_BTF_ID) via the target program translation.
During attachment in kernel/bpf/trampoline.c:__bpf_trampoline_link_prog(),
the safeguard calls bpf_prog_has_arena_ctx_arg(node->link->prog) on the
attaching program instead of the target program. Because the attaching program
lacks ctx_arg_info, this check returns false and allows the unsafe attachment
to proceed.
At runtime, the struct_ops trampoline converts the kernel pointer to a 32-bit
arena offset in the context array. Since the extension or tracing program was
verified believing this argument is a PTR_TO_BTF_ID, could this allow it to
dereference a user-controlled 32-bit arena offset as a trusted kernel pointer?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260805210427.3218326-1-memxor@gmail.com?part=5
next prev parent reply other threads:[~2026-08-05 21:18 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 21:04 [PATCH bpf-next v4 00/13] Add arena argument support to kfuncs and struct_ops Kumar Kartikeya Dwivedi
2026-08-05 21:04 ` [PATCH bpf-next v4 01/13] bpf: Rename 'early' BTF checking as a preparation phase Kumar Kartikeya Dwivedi
2026-08-06 16:29 ` Amery Hung
2026-08-05 21:04 ` [PATCH bpf-next v4 02/13] bpf: Split subprogram and kfunc collection Kumar Kartikeya Dwivedi
2026-08-05 21:49 ` bot+bpf-ci
2026-08-06 16:31 ` Amery Hung
2026-08-05 21:04 ` [PATCH bpf-next v4 03/13] bpf: Collect kfuncs after resolving program resources Kumar Kartikeya Dwivedi
2026-08-06 16:37 ` Amery Hung
2026-08-05 21:04 ` [PATCH bpf-next v4 04/13] bpf: Support __arena and __arena__nullable kfunc argument suffixes Kumar Kartikeya Dwivedi
2026-08-06 17:22 ` Amery Hung
2026-08-06 19:20 ` Kumar Kartikeya Dwivedi
2026-08-06 19:23 ` Kumar Kartikeya Dwivedi
2026-08-06 19:31 ` Amery Hung
2026-08-07 0:51 ` Eduard Zingerman
2026-08-05 21:04 ` [PATCH bpf-next v4 05/13] bpf: Support __arena and __arena__nullable on struct_ops arguments Kumar Kartikeya Dwivedi
2026-08-05 21:18 ` sashiko-bot [this message]
2026-08-07 0:51 ` Eduard Zingerman
2026-08-05 21:04 ` [PATCH bpf-next v4 06/13] bpf, x86: JIT __arena kfunc argument rebasing Kumar Kartikeya Dwivedi
2026-08-05 21:04 ` [PATCH bpf-next v4 07/13] bpf, x86: Convert struct_ops arena arguments in the trampoline Kumar Kartikeya Dwivedi
2026-08-07 4:09 ` Eduard Zingerman
2026-08-05 21:04 ` [PATCH bpf-next v4 08/13] selftests/bpf: Add kfunc __arena and __arena__nullable argument tests Kumar Kartikeya Dwivedi
2026-08-07 4:44 ` Eduard Zingerman
2026-08-05 21:04 ` [PATCH bpf-next v4 09/13] selftests/bpf: Add JIT-sequence tests for __arena kfunc arguments Kumar Kartikeya Dwivedi
2026-08-07 4:45 ` Eduard Zingerman
2026-08-05 21:04 ` [PATCH bpf-next v4 10/13] selftests/bpf: Add struct_ops __arena and __arena__nullable argument tests Kumar Kartikeya Dwivedi
2026-08-05 21:15 ` sashiko-bot
2026-08-05 21:04 ` [PATCH bpf-next v4 11/13] bpf, x86: Fix stack-passed arguments for indirect trampolines Kumar Kartikeya Dwivedi
2026-08-05 21:15 ` sashiko-bot
2026-08-05 21:04 ` [PATCH bpf-next v4 12/13] selftests/bpf: Test stack-passed struct_ops arena arguments Kumar Kartikeya Dwivedi
2026-08-05 21:04 ` [PATCH bpf-next v4 13/13] bpf: Reject tracing progs for struct_ops with arena args Kumar Kartikeya Dwivedi
2026-08-05 22:02 ` bot+bpf-ci
2026-08-07 4:51 ` 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=20260805211850.CBFAF1F000E9@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