From: sashiko-bot@kernel.org
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v5 10/14] selftests/bpf: Add struct_ops __arena and __arena__nullable argument tests
Date: Sat, 08 Aug 2026 01:03:31 +0000 [thread overview]
Message-ID: <20260808010332.90C021F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260808003938.3486067-11-memxor@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unsafe unconditional dereference of `st_ops3` and its callbacks in the newly added kfuncs, leading to a kernel panic.
--
--- Patch [10]: [PATCH bpf-next v5 10/14] selftests/bpf: Add struct_ops __arena and __arena__nullable argument tests ---
commit ca58e222e16e38d0927f0dd75956c9489242a175
Author: Tejun Heo <tj@kernel.org>
selftests/bpf: Add struct_ops __arena and __arena__nullable argument tests
This patch adds test_arena and test_arena_nullable members to bpf_testmod_ops3
with arena-tagged arguments. It also introduces kfuncs that forward caller-
provided pointers to them to test end-to-end conversions of arena pointers.
> diff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
> index 2291bb4665178..1e6d632c6f836 100644
> --- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
> +++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
[ ... ]
> @@ -406,6 +418,16 @@ __bpf_kfunc void bpf_testmod_ops3_call_test_2(void)
> st_ops3->test_2();
> }
>
> +__bpf_kfunc int bpf_testmod_ops3_call_test_arena(u64 *ptr__arena)
> +{
> + return st_ops3->test_arena(ptr__arena);
[Severity: High]
Does this code risk a NULL pointer dereference if st_ops3 has not been set yet?
The global pointer st_ops3 is initialized to NULL and only set when a struct_ops
map is explicitly registered. A BPF program could trigger a kernel panic by
invoking this kfunc via BPF_PROG_RUN before the map is attached, or concurrently
during teardown.
While this pattern is also used in the pre-existing bpf_testmod_ops3_call_test_1()
kfunc, should st_ops3 be checked for NULL, potentially while holding
st_ops_mutex, before dereferencing it here?
> +}
> +
> +__bpf_kfunc int bpf_testmod_ops3_call_test_arena_nullable(u64 *ptr__arena__nullable)
> +{
> + return st_ops3->test_arena_nullable(ptr__arena__nullable);
[Severity: High]
Similarly, can this unconditionally dereference st_ops3 when it is NULL?
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260808003938.3486067-1-memxor@gmail.com?part=10
next prev parent reply other threads:[~2026-08-08 1:03 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-08 0:39 [PATCH bpf-next v5 00/14] Add arena argument support to kfuncs and struct_ops Kumar Kartikeya Dwivedi
2026-08-08 0:39 ` [PATCH bpf-next v5 01/14] bpf: Rename 'early' BTF checking as a preparation phase Kumar Kartikeya Dwivedi
2026-08-08 0:39 ` [PATCH bpf-next v5 02/14] bpf: Split subprogram and kfunc collection Kumar Kartikeya Dwivedi
2026-08-08 1:59 ` bot+bpf-ci
2026-08-08 0:39 ` [PATCH bpf-next v5 03/14] bpf: Collect kfuncs after resolving program resources Kumar Kartikeya Dwivedi
2026-08-08 0:39 ` [PATCH bpf-next v5 04/14] bpf: Support __arena and __arena__nullable kfunc argument suffixes Kumar Kartikeya Dwivedi
2026-08-08 0:39 ` [PATCH bpf-next v5 05/14] bpf: Support __arena and __arena__nullable on struct_ops arguments Kumar Kartikeya Dwivedi
2026-08-08 1:17 ` sashiko-bot
2026-08-08 9:49 ` Eduard Zingerman
2026-08-08 0:39 ` [PATCH bpf-next v5 06/14] bpf, x86: JIT __arena kfunc argument rebasing Kumar Kartikeya Dwivedi
2026-08-08 0:39 ` [PATCH bpf-next v5 07/14] bpf, x86: Convert struct_ops arena arguments in the trampoline Kumar Kartikeya Dwivedi
2026-08-08 0:39 ` [PATCH bpf-next v5 08/14] selftests/bpf: Add kfunc __arena and __arena__nullable argument tests Kumar Kartikeya Dwivedi
2026-08-08 0:39 ` [PATCH bpf-next v5 09/14] selftests/bpf: Add JIT-sequence tests for __arena kfunc arguments Kumar Kartikeya Dwivedi
2026-08-08 0:39 ` [PATCH bpf-next v5 10/14] selftests/bpf: Add struct_ops __arena and __arena__nullable argument tests Kumar Kartikeya Dwivedi
2026-08-08 1:03 ` sashiko-bot [this message]
2026-08-08 0:39 ` [PATCH bpf-next v5 11/14] bpf, x86: Fix stack-passed arguments for indirect trampolines Kumar Kartikeya Dwivedi
2026-08-08 1:04 ` sashiko-bot
2026-08-08 0:39 ` [PATCH bpf-next v5 12/14] selftests/bpf: Test stack-passed struct_ops arena arguments Kumar Kartikeya Dwivedi
2026-08-08 0:39 ` [PATCH bpf-next v5 13/14] bpf: Reject tracing/freplace progs for struct_ops with arena args Kumar Kartikeya Dwivedi
2026-08-08 1:17 ` sashiko-bot
2026-08-08 9:57 ` Eduard Zingerman
2026-08-08 0:39 ` [PATCH bpf-next v5 14/14] selftests/bpf: Test attach rejection for struct_ops arena programs Kumar Kartikeya Dwivedi
2026-08-08 9:58 ` Eduard Zingerman
2026-08-08 10:10 ` [PATCH bpf-next v5 00/14] Add arena argument support to kfuncs and struct_ops patchwork-bot+netdevbpf
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=20260808010332.90C021F000E9@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