BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "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 23:03:39 +0000	[thread overview]
Message-ID: <20260706230339.A8A981F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260706225052.35543-1-emil@etsalapatis.com>

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?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260706225052.35543-1-emil@etsalapatis.com?part=1

  reply	other threads:[~2026-07-06 23:03 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 [this message]
2026-07-07  0:21   ` 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=20260706230339.A8A981F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=emil@etsalapatis.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox