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 RESEND bpf-next v2] selftests/bpf: veristat: Minimize map size during verification
Date: Tue, 07 Jul 2026 16:39:52 +0000	[thread overview]
Message-ID: <20260707163953.279CB1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260707162012.8063-1-emil@etsalapatis.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] veristat overrides BPF_MAP_TYPE_HASH_OF_MAPS max_entries to 1, causing map preparation to fail for declaratively initialized maps
--

--- Patch [1]: [PATCH RESEND bpf-next v2] selftests/bpf: veristat: Minimize map size during verification ---
commit be52ac6965be2ec63632786bb06d60b4e6152bc6
Author: Emil Tsalapatis <emil@etsalapatis.com>

selftests/bpf: veristat: Minimize map size during verification

This commit updates veristat to resize BPF maps where max_entries is
irrelevant to the verification process. By shrinking these maps to the
minimum size, it avoids -ENOMEM errors on memory-constrained systems.

> diff --git a/tools/testing/selftests/bpf/veristat.c b/tools/testing/selftests/bpf/veristat.c
> --- a/tools/testing/selftests/bpf/veristat.c
> +++ b/tools/testing/selftests/bpf/veristat.c
> @@ -1248,6 +1248,30 @@ 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:

[Severity: Medium]
Will this cause map preparation to fail with -E2BIG if there are multiple
inner maps declaratively initialized?

In fixup_obj_maps(), if the outer map's max_entries is forcibly overridden to 1,
when libbpf later attempts to populate the slots via bpf_map_update_elem()
during bpf_object__prepare(), the first insertion succeeds, but subsequent
insertions fail because the hash map's capacity is constrained to 1.

Does this mean tests that declaratively initialize multiple inner maps
(such as test_btf_map_in_map.bpf.o) will fail to load with invalid map FDs,
subsequently causing the verifier to reject the programs?

> +		case BPF_MAP_TYPE_SOCKHASH:
[ ... ]

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

      reply	other threads:[~2026-07-07 16:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 16:20 [PATCH RESEND bpf-next v2] selftests/bpf: veristat: Minimize map size during verification Emil Tsalapatis
2026-07-07 16:39 ` sashiko-bot [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=20260707163953.279CB1F000E9@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