From: "Emil Tsalapatis" <emil@etsalapatis.com>
To: <bot+bpf-ci@kernel.org>, <emil@etsalapatis.com>, <bpf@vger.kernel.org>
Cc: <ast@kernel.org>, <andrii@kernel.org>, <memxor@gmail.com>,
<daniel@iogearbox.net>, <eddyz87@gmail.com>, <song@kernel.org>,
<martin.lau@kernel.org>, <yonghong.song@linux.dev>,
<clm@meta.com>, <ihor.solodrai@linux.dev>
Subject: Re: [PATCH bpf-next v5 1/9] bpf: Upgrade scalar to PTR_TO_ARENA on arena pointer addition
Date: Fri, 10 Apr 2026 13:55:41 -0400 [thread overview]
Message-ID: <DHPO2G9QEDHI.ERBXQTHDKU02@etsalapatis.com> (raw)
In-Reply-To: <44b371bad4d974ab7a780fde68c937820201144e17e2b5a26e908dbffae19f4e@mail.kernel.org>
On Fri Apr 10, 2026 at 1:34 PM EDT, bot+bpf-ci wrote:
>> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
>> index 9c1135d373e24..6c5721434bc4b 100644
>> --- a/kernel/bpf/verifier.c
>> +++ b/kernel/bpf/verifier.c
>> @@ -16655,11 +16655,32 @@ static int adjust_reg_min_max_vals(struct bpf_verifier_env *env,
>
> [ ... ]
>
>> + if (dst_reg->type != PTR_TO_ARENA) {
>> + /* Can't do arena arithmetic with non-scalars. */
>> + if (dst_reg->type != SCALAR_VALUE) {
>> + verbose(env, "R%d %s R%d: Invalid operation between "
>> + "bpf_reg_state types %s and %s\n",
>> + insn->dst_reg,
>> + bpf_alu_string[opcode >> 4],
>> + insn->src_reg,
>> + reg_type_str(env, dst_reg->type),
>> + reg_type_str(env, src_reg->type));
>
> reg_type_str() returns a pointer to the shared buffer env->tmp_str_buf.
> Its own comment in log.c says:
>
> Note that reg_type_str() can not appear more than once in a
> single verbose() statement.
>
> Calling it twice in the same verbose() here means both %s arguments
> point to the same buffer, so the error message will display one of the
> two type names twice and the other not at all.
>
> Would it work to split this into two verbose() calls, or save one
> result to a local buffer before printing?
>
Ack. We can just split this into two verbose() statements.
>> + return -EACCES;
>> + }
>> +
>> + *dst_reg = *src_reg;
>> + dst_reg->subreg_def = env->insn_idx + 1;
>> + }
>
> [ ... ]
>
> This commit fixes a bug where the verifier rejects valid BPF programs
> when the compiler places the result of a PTR_TO_ARENA + SCALAR addition
> into the scalar register. The bug was introduced by commit 6082b6c328b5
> ("bpf: Recognize addr_space_cast instruction in the verifier.") which
> added the original PTR_TO_ARENA handling in the verifier.
>
> This was also noted during review of the v3 series on lore, and the
> Fixes: tag was acknowledged but appears to be missing from the final
> version. Should this carry:
>
> Fixes: 6082b6c328b5 ("bpf: Recognize addr_space_cast instruction in the verifier.")
>
Not sure actually. The original patch logic was overly restrictive, but
it's not like it was broken. This code is more of an expansion than a
fix imo.
>
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
>
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/24254055723
next prev parent reply other threads:[~2026-04-10 17:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-10 16:30 [PATCH bpf-next v5 0/9] Introduce arena library and runtime Emil Tsalapatis
2026-04-10 16:30 ` [PATCH bpf-next v5 1/9] bpf: Upgrade scalar to PTR_TO_ARENA on arena pointer addition Emil Tsalapatis
2026-04-10 17:34 ` bot+bpf-ci
2026-04-10 17:55 ` Emil Tsalapatis [this message]
2026-04-10 16:30 ` [PATCH bpf-next v5 2/9] selftests/bpf: Add test for scalar/arena " Emil Tsalapatis
2026-04-10 16:30 ` [PATCH bpf-next v5 3/9] selftests/bpf: Move bpf_arena_spin_lock.h to the top level Emil Tsalapatis
2026-04-10 16:30 ` [PATCH bpf-next v5 4/9] selftests/bpf: Deduplicate WRITE_ONCE macro between headers Emil Tsalapatis
2026-04-10 16:30 ` [PATCH bpf-next v5 5/9] selftests/bpf: Add basic libarena scaffolding Emil Tsalapatis
2026-04-10 18:39 ` Song Liu
2026-04-10 19:44 ` Kumar Kartikeya Dwivedi
2026-04-10 16:30 ` [PATCH bpf-next v5 6/9] selftests/bpf: Add arena ASAN runtime to libarena Emil Tsalapatis
2026-04-10 16:30 ` [PATCH bpf-next v5 7/9] selftests/bpf: Add ASAN support for libarena selftests Emil Tsalapatis
2026-04-10 16:30 ` [PATCH bpf-next v5 8/9] selftests/bpf: Add buddy allocator for libarena Emil Tsalapatis
2026-04-10 16:30 ` [PATCH bpf-next v5 9/9] selftests/bpf: Add selftests for libarena buddy allocator Emil Tsalapatis
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=DHPO2G9QEDHI.ERBXQTHDKU02@etsalapatis.com \
--to=emil@etsalapatis.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bot+bpf-ci@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clm@meta.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=martin.lau@kernel.org \
--cc=memxor@gmail.com \
--cc=song@kernel.org \
--cc=yonghong.song@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