From: Eduard Zingerman <eddyz87@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Emil Tsalapatis <emil@etsalapatis.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
memxor@gmail.com, daniel@iogearbox.net
Subject: Re: [PATCH bpf-next v3] selftests/bpf: veristat: Minimize map size during verification
Date: Fri, 10 Jul 2026 14:50:31 -0700 [thread overview]
Message-ID: <cbee8f83f6e11ac58afa366317d52e64473b2736.camel@gmail.com> (raw)
In-Reply-To: <CAEf4Bzarum7QXKT+BuvBa9kSrjMX=BzknWFKQBQuROKOWFeuZQ@mail.gmail.com>
On Fri, 2026-07-10 at 14:44 -0700, Andrii Nakryiko wrote:
[...]
> > @@ -1248,6 +1248,29 @@ static void fixup_obj_maps(struct bpf_object *obj)
> >
> > /* fix up map size, if necessary */
> > switch (bpf_map__type(map)) {
> > + /*
> > + * if the verifier doesn't use max_entries
> > + * then set to 1 to avoid -ENOMEM
> > + */
> > + case BPF_MAP_TYPE_HASH:
>
>
> I'm wondering if we should add ARRAY here as that one is actually with
> high likelihood will be large, though there are some corner cases
> where size might matter (e.g., existing code omits error checking
> knowing that verifier will prove it can never fail; resizing to 1
> might pessimize such check, probably, if index is larger than 1). Can
> you actually try the latter scenario with some small program, I'm
> curious how the verifier will behave?
For array maps there are several complications: first is the constant
maps handling and second is null check elision. The latter is somewhat
nasty, see check_helper_call():
case RET_PTR_TO_MAP_VALUE:
...
if (func_id == BPF_FUNC_map_lookup_elem &&
can_elide_value_nullness(meta.map.ptr) && <-------- true for array maps
meta.const_map_key >= 0 &&
meta.const_map_key < meta.map.ptr->max_entries) <-- checks max_entries
ret_flag &= ~PTR_MAYBE_NULL;
[...]
next prev parent reply other threads:[~2026-07-10 21:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 19:32 [PATCH bpf-next v3] selftests/bpf: veristat: Minimize map size during verification Emil Tsalapatis
2026-07-10 21:44 ` Andrii Nakryiko
2026-07-10 21:50 ` Eduard Zingerman [this message]
2026-07-10 22:31 ` Andrii Nakryiko
2026-07-10 21:50 ` 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=cbee8f83f6e11ac58afa366317d52e64473b2736.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=emil@etsalapatis.com \
--cc=memxor@gmail.com \
/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