From: sashiko-bot@kernel.org
To: "Emil Tsalapatis" <emil@etsalapatis.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 5/6] selftests/bpf: libarena: Directly return arena pointers from functions
Date: Tue, 02 Jun 2026 01:45:33 +0000 [thread overview]
Message-ID: <20260602014534.647AA1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260602004120.17087-6-emil@etsalapatis.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Returning `void __arena *` natively from global subprograms causes verifier rejection due to the omission of the `addr_space_cast` instruction.
--
commit cebc1ff5de4bdc037926c8cf353b253eb29e111c
Author: Emil Tsalapatis <emil@etsalapatis.com>
selftests/bpf: libarena: Directly return arena pointers from functions
This commit updates the libarena functions to directly return arena pointers
instead of returning u64 and relying on preprocessor macros for type casting
to hide the conversion from the caller.
> diff --git a/tools/testing/selftests/bpf/libarena/include/libarena/buddy.h b/tools/testing/selftests/bpf/libarena/include/libarena/buddy.h
> index 4d57fc1b5c26f..528c69a1f38e0 100644
> --- a/tools/testing/selftests/bpf/libarena/include/libarena/buddy.h
> +++ b/tools/testing/selftests/bpf/libarena/include/libarena/buddy.h
> @@ -76,7 +76,6 @@ struct buddy {
> int buddy_init(struct buddy __arena *buddy);
> int buddy_destroy(struct buddy __arena *buddy);
> int buddy_free(struct buddy __arena *buddy, void __arena *free);
> -u64 buddy_alloc_internal(struct buddy __arena *buddy, size_t size);
> -#define buddy_alloc(alloc, size) ((void __arena *)buddy_alloc_internal((alloc), (size)))
> +void __arena *buddy_alloc(struct buddy __arena *buddy, size_t size);
[Severity: High]
Does changing the return type to void __arena * break the BPF verifier for
programs calling these functions?
Since this change removes the explicit C-style cast from a u64, Clang will
no longer emit the BPF_ADDR_SPACE_CAST instruction because both sides of
the assignment share the same address space.
However, in kernel/bpf/verifier.c:check_func_call(), the verifier still
forces the return register (R0) of all global subprograms to SCALAR_VALUE:
if (!subprog_returns_void(env, subprog)) {
mark_reg_unknown(env, caller->regs, BPF_REG_0);
caller->regs[BPF_REG_0].subreg_def = DEF_NOT_SUBREG;
}
Without the addr_space_cast instruction to upgrade the SCALAR_VALUE back
to a PTR_TO_ARENA, will subsequent memory accesses using this returned
pointer be rejected by the verifier with an "invalid mem access 'scalar'"
error?
It appears check_func_call() might need to be updated to populate the caller's
R0 state with PTR_TO_ARENA based on the BTF return type before this test can
safely rely on native arena pointer returns.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260602004120.17087-1-emil@etsalapatis.com?part=5
next prev parent reply other threads:[~2026-06-02 1:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 0:41 [PATCH bpf-next v3 0/6] Minimize annotations for arena programs Emil Tsalapatis
2026-06-02 0:41 ` [PATCH bpf-next v3 1/6] selftests/bpf: libarena: Add "arena" BTF type tag to __arena qualifier Emil Tsalapatis
2026-06-02 0:41 ` [PATCH bpf-next v3 2/6] verifier: parse BTF type tags for function arguments Emil Tsalapatis
2026-06-02 1:05 ` sashiko-bot
2026-06-02 1:05 ` Emil Tsalapatis
2026-06-02 1:26 ` bot+bpf-ci
2026-06-02 0:41 ` [PATCH bpf-next v3 3/6] bpf: Allow subprogs to return arena pointers Emil Tsalapatis
2026-06-02 1:20 ` sashiko-bot
2026-06-02 0:41 ` [PATCH bpf-next v3 4/6] selftests/bpf: Remove __arg_arena from the codebase Emil Tsalapatis
2026-06-02 1:31 ` sashiko-bot
2026-06-02 0:41 ` [PATCH bpf-next v3 5/6] selftests/bpf: libarena: Directly return arena pointers from functions Emil Tsalapatis
2026-06-02 1:45 ` sashiko-bot [this message]
2026-06-02 0:41 ` [PATCH bpf-next v3 6/6] selftests/bpf: Add tests for the new type-tag based __arena identifier Emil Tsalapatis
2026-06-02 2:00 ` [PATCH bpf-next v3 0/6] Minimize annotations for arena programs 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=20260602014534.647AA1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=emil@etsalapatis.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.