From: "Emil Tsalapatis" <emil@etsalapatis.com>
To: <sashiko-reviews@lists.linux.dev>,
"Emil Tsalapatis" <emil@etsalapatis.com>
Cc: <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf-next] selftests/bpf: veristat: Minimize map size during verification
Date: Mon, 06 Jul 2026 20:21:03 -0400 [thread overview]
Message-ID: <DJRWQWKLMY87.5ING2IA83CYG@etsalapatis.com> (raw)
In-Reply-To: <20260706230339.A8A981F000E9@smtp.kernel.org>
On Mon Jul 6, 2026 at 7:03 PM EDT, sashiko-bot wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] Setting `max_entries` to 1 for `BPF_MAP_TYPE_RHASH` maps causes map creation to fail if `map_extra` > 1.
> --
>
> --- Patch [1]: [PATCH bpf-next] selftests/bpf: veristat: Minimize map size during verification ---
> commit a11623d3f77bb05764867d10c3ff357f2a8a1403
> Author: Emil Tsalapatis <emil@etsalapatis.com>
>
> selftests/bpf: veristat: Minimize map size during verification
>
> The veristat tool loads objects and maps into the kernel to verify them.
> This patch expands veristat to resize maps whose max_entries are not
> relevant to verification to as low as possible to avoid -ENOMEM errors
> on smaller test machines.
>
>> diff --git a/tools/testing/selftests/bpf/veristat.c b/tools/testing/selftests/bpf/veristat.c
>> index a7db6f04f7e14..8d374e1406532 100644
>> --- a/tools/testing/selftests/bpf/veristat.c
>> +++ b/tools/testing/selftests/bpf/veristat.c
> [ ... ]
>> @@ -1248,6 +1263,37 @@ 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:
>> + case BPF_MAP_TYPE_PERCPU_HASH:
>> + case BPF_MAP_TYPE_LRU_HASH:
>> + case BPF_MAP_TYPE_LRU_PERCPU_HASH:
>> + case BPF_MAP_TYPE_HASH_OF_MAPS:
>> + case BPF_MAP_TYPE_RHASH:
>> + case BPF_MAP_TYPE_SOCKHASH:
>> + case BPF_MAP_TYPE_DEVMAP_HASH:
>> + case BPF_MAP_TYPE_LPM_TRIE:
>> + case BPF_MAP_TYPE_QUEUE:
>> + case BPF_MAP_TYPE_STACK:
>> + case BPF_MAP_TYPE_BLOOM_FILTER:
>> + case BPF_MAP_TYPE_STACK_TRACE:
>> + bpf_map__set_max_entries(map, 1);
>> + break;
>
> [Severity: Medium]
> Will setting max_entries to 1 cause map creation to fail for
> BPF_MAP_TYPE_RHASH maps that have map_extra set to greater than 1?
>
> The kernel's rhtab_map_alloc_check() enforces that map_extra must be less
> than or equal to max_entries. If a BPF program legitimately uses an RHASH
> map with a map_extra preallocation hint greater than 1, this unconditional
> minimization will cause an -EINVAL load failure, making veristat erroneously
> report a verification failure.
>
> Does veristat also need to adjust map_extra when reducing max_entries for
> RHASH maps?
The concern is valid, the fix imo is not. Rhashtable is resizable in the
first place, so we shouldn't be trying to reduce its maximum entries.
Same holds for LPM_TRIE and for arena (my worry was we do a memcg
reservation upfront but that's not the case). We can just remove all
three from the list to fix this issue and simplify the patch.
prev parent reply other threads:[~2026-07-07 0:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 22:50 [PATCH bpf-next] selftests/bpf: veristat: Minimize map size during verification Emil Tsalapatis
2026-07-06 23:03 ` sashiko-bot
2026-07-07 0:21 ` Emil Tsalapatis [this message]
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=DJRWQWKLMY87.5ING2IA83CYG@etsalapatis.com \
--to=emil@etsalapatis.com \
--cc=bpf@vger.kernel.org \
--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.