From: Emil Tsalapatis <emil@etsalapatis.com>
To: bpf@vger.kernel.org
Cc: andrii@kernel.org, eddyz87@gmail.com, ast@kernel.org,
daniel@iogearbox.net, john.fastabend@gmail.com, memxor@gmail.com,
yonghong.song@linux.dev, Emil Tsalapatis <emil@etsalapatis.com>
Subject: [PATCH v2 2/4] bpf/verifier: do not limit maximum direct offset into arena map
Date: Wed, 3 Dec 2025 11:26:23 -0500 [thread overview]
Message-ID: <20251203162625.13152-3-emil@etsalapatis.com> (raw)
In-Reply-To: <20251203162625.13152-1-emil@etsalapatis.com>
The verifier currently limits direct offsets into a map to 512MiB
to avoid overflow during pointer arithmetic. However, this prevents
arena maps from using direct addressing instructions to access data
at the end of > 512MiB arena maps. This is necessary when moving
arena globals to the end of the arena instead of the front.
Relax the limitation for direct offsets into arena maps to 4GiB,
the maximum arena size.
Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com>
---
kernel/bpf/verifier.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 098dd7f21c89..a64cc5caf4aa 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -21084,13 +21084,13 @@ static int resolve_pseudo_ldimm64(struct bpf_verifier_env *env)
} else {
u32 off = insn[1].imm;
- if (off >= BPF_MAX_VAR_OFF) {
- verbose(env, "direct value offset of %u is not allowed\n", off);
+ if (!map->ops->map_direct_value_addr) {
+ verbose(env, "no direct value access support for this map type\n");
return -EINVAL;
}
- if (!map->ops->map_direct_value_addr) {
- verbose(env, "no direct value access support for this map type\n");
+ if (off >= BPF_MAX_VAR_OFF && map->map_type != BPF_MAP_TYPE_ARENA) {
+ verbose(env, "direct value offset of %u is not allowed\n", off);
return -EINVAL;
}
--
2.49.0
next prev parent reply other threads:[~2025-12-03 16:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-03 16:26 [PATCH v2 0/4] libbpf: move arena variables out of the zero Emil Tsalapatis
2025-12-03 16:26 ` [PATCH v2 1/4] selftests/bpf: explicitly account for globals in verifier_arena_large Emil Tsalapatis
2025-12-03 16:26 ` Emil Tsalapatis [this message]
2025-12-06 0:11 ` [PATCH v2 2/4] bpf/verifier: do not limit maximum direct offset into arena map Andrii Nakryiko
2025-12-03 16:26 ` [PATCH v2 3/4] libbpf: move arena globals to the end of the arena Emil Tsalapatis
2025-12-03 16:52 ` bot+bpf-ci
2025-12-06 0:11 ` Andrii Nakryiko
2025-12-08 22:30 ` Emil Tsalapatis
2025-12-06 0:11 ` Andrii Nakryiko
2025-12-03 16:26 ` [PATCH v2 4/4] selftests/bpf: add tests for the arena offset of globals Emil Tsalapatis
2025-12-06 0:11 ` [PATCH v2 0/4] libbpf: move arena variables out of the zero Andrii Nakryiko
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=20251203162625.13152-3-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=john.fastabend@gmail.com \
--cc=memxor@gmail.com \
--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