From: Emil Tsalapatis <emil@etsalapatis.com>
To: bpf@vger.kernel.org
Cc: ast@kernel.org, andrii@kernel.org, memxor@gmail.com,
daniel@iogearbox.net, eddyz87@gmail.com, song@kernel.org,
Emil Tsalapatis <emil@etsalapatis.com>
Subject: [PATCH bpf-next v7 1/9] bpf: Allow instructions with arena source and non-arena dest registers
Date: Sun, 12 Apr 2026 13:45:38 -0400 [thread overview]
Message-ID: <20260412174546.18684-2-emil@etsalapatis.com> (raw)
In-Reply-To: <20260412174546.18684-1-emil@etsalapatis.com>
The compiler sometimes stores the result of a PTR_TO_ARENA and SCALAR
operation into the scalar register rather than the pointer register.
Relax the verifier to allow operations between a source arena register
and a destination non-arena register, marking the destination's value
as a PTR_TO_ARENA.
Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com>
Acked-by: Song Liu <song@kernel.org>
Fixes: 6082b6c328b5 ("bpf: Recognize addr_space_cast instruction in the verifier.")
---
kernel/bpf/verifier.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 9c1135d373e2..9280b3aaae46 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -16655,11 +16655,21 @@ static int adjust_reg_min_max_vals(struct bpf_verifier_env *env,
int err;
dst_reg = ®s[insn->dst_reg];
- src_reg = NULL;
+ if (BPF_SRC(insn->code) == BPF_X)
+ src_reg = ®s[insn->src_reg];
+ else
+ src_reg = NULL;
- if (dst_reg->type == PTR_TO_ARENA) {
+ /* Case where at least one operand is an arena. */
+ if (dst_reg->type == PTR_TO_ARENA || (src_reg && src_reg->type == PTR_TO_ARENA)) {
struct bpf_insn_aux_data *aux = cur_aux(env);
+ /* If dst_reg wasn't PTR_TO_ARENA, it is now. */
+ if (dst_reg->type != PTR_TO_ARENA)
+ *dst_reg = *src_reg;
+
+ dst_reg->subreg_def = env->insn_idx + 1;
+
if (BPF_CLASS(insn->code) == BPF_ALU64)
/*
* 32-bit operations zero upper bits automatically.
--
2.53.0
next prev parent reply other threads:[~2026-04-12 17:45 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-12 17:45 [PATCH bpf-next v7 0/9] Introduce arena library and runtime Emil Tsalapatis
2026-04-12 17:45 ` Emil Tsalapatis [this message]
2026-04-12 19:54 ` [PATCH bpf-next v7 1/9] bpf: Allow instructions with arena source and non-arena dest registers Alexei Starovoitov
2026-04-12 17:45 ` [PATCH bpf-next v7 2/9] selftests/bpf: Add tests for non-arena/arena operations Emil Tsalapatis
2026-04-12 17:45 ` [PATCH bpf-next v7 3/9] selftests/bpf: Move bpf_arena_spin_lock.h to the top level Emil Tsalapatis
2026-04-12 19:31 ` Kumar Kartikeya Dwivedi
2026-04-12 17:45 ` [PATCH bpf-next v7 4/9] selftests/bpf: Move READ_ONCE/WRITE_ONCE macros to bpf_experimental.h Emil Tsalapatis
2026-04-12 19:33 ` Kumar Kartikeya Dwivedi
2026-04-12 17:45 ` [PATCH bpf-next v7 5/9] selftests/bpf: Add basic libarena scaffolding Emil Tsalapatis
2026-04-12 18:28 ` bot+bpf-ci
2026-04-12 18:31 ` Emil Tsalapatis
2026-04-12 17:45 ` [PATCH bpf-next v7 6/9] selftests/bpf: Add arena ASAN runtime to libarena Emil Tsalapatis
2026-04-12 18:28 ` bot+bpf-ci
2026-04-12 18:34 ` Emil Tsalapatis
2026-04-12 17:45 ` [PATCH bpf-next v7 7/9] selftests/bpf: Add ASAN support for libarena selftests Emil Tsalapatis
2026-04-12 17:45 ` [PATCH bpf-next v7 8/9] selftests/bpf: Add buddy allocator for libarena Emil Tsalapatis
2026-04-12 17:45 ` [PATCH bpf-next v7 9/9] selftests/bpf: Add selftests for libarena buddy allocator Emil Tsalapatis
2026-04-12 19:22 ` [PATCH bpf-next v7 0/9] Introduce arena library and runtime Kumar Kartikeya Dwivedi
2026-04-12 20:00 ` 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=20260412174546.18684-2-emil@etsalapatis.com \
--to=emil@etsalapatis.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=memxor@gmail.com \
--cc=song@kernel.org \
/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