All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mykyta Yatsenko" <mykyta.yatsenko5@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v7 10/12] selftests/bpf: Add BPF iterator tests for resizable hash map
Date: Fri, 05 Jun 2026 11:56:20 +0000	[thread overview]
Message-ID: <20260605115620.F1B7C1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260605-rhash-v7-10-5b8e05f8630d@meta.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The BPF iterator test `rhash_iter_test` does not verify that `read()` completed without an error.
--

commit 80a3099ee25442fbc4f994c884097e00ff4bfc97
Author: Mykyta Yatsenko <yatsenko@meta.com>

selftests/bpf: Add BPF iterator tests for resizable hash map

This commit tests basic BPF iterator functionality for BPF_MAP_TYPE_RHASH,
verifying all elements are visited.

> diff --git a/tools/testing/selftests/bpf/prog_tests/rhash.c b/tools/testing/selftests/bpf/prog_tests/rhash.c
> index 69686bf69ba57..98bb66907b7f7 100644
> --- a/tools/testing/selftests/bpf/prog_tests/rhash.c
> +++ b/tools/testing/selftests/bpf/prog_tests/rhash.c

[ ... ]

> @@ -89,6 +90,65 @@ static void rhash_map_extra_too_big(void)
>  		close(fd);
>  }
>  
> +static void rhash_iter_test(void)
> +{

[ ... ]

> +	iter_fd = bpf_iter_create(bpf_link__fd(link));
> +	if (!ASSERT_GE(iter_fd, 0, "create_iter"))
> +		goto free_link;
> +
> +	do {
> +		len = read(iter_fd, buf, sizeof(buf));
> +	} while (len > 0);

[Severity: Medium]
Could this loop silently swallow errors if read() returns a negative value?

If read() returns an error, the loop will exit silently. If an error occurs
after all map elements have already been processed by the BPF program, the
subsequent assertions on key_sum and elem_count might still pass, which would
completely mask the failure. 

Would it make sense to add an explicit ASSERT_GE(len, 0, "read") after the
loop to ensure read() completes without error?

> +
> +	ASSERT_EQ(skel->bss->key_sum, expected_key_sum, "key_sum");
> +	ASSERT_EQ(skel->bss->elem_count, 64, "elem_count");
> +
> +	close(iter_fd);

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260605-rhash-v7-0-5b8e05f8630d@meta.com?part=10

  reply	other threads:[~2026-06-05 11:56 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-05 11:41 [PATCH bpf-next v7 00/12] bpf: Introduce resizable hash map Mykyta Yatsenko
2026-06-05 11:41 ` [PATCH bpf-next v7 01/12] rhashtable: Add rhashtable_next_key() API Mykyta Yatsenko
2026-06-05 11:43   ` Herbert Xu
2026-06-05 11:41 ` [PATCH bpf-next v7 02/12] rhashtable: Add selftest for rhashtable_next_key() Mykyta Yatsenko
2026-06-05 11:43   ` Herbert Xu
2026-06-05 11:41 ` [PATCH bpf-next v7 03/12] rhashtable: Use irq work for shrinking Mykyta Yatsenko
2026-06-05 12:40   ` bot+bpf-ci
2026-06-05 11:41 ` [PATCH bpf-next v7 04/12] bpf: Implement resizable hashmap basic functions Mykyta Yatsenko
2026-06-05 11:41 ` [PATCH bpf-next v7 05/12] bpf: Implement iteration ops for resizable hashtab Mykyta Yatsenko
2026-06-05 11:56   ` sashiko-bot
2026-06-05 12:40   ` bot+bpf-ci
2026-06-05 11:41 ` [PATCH bpf-next v7 06/12] bpf: Allow special fields in " Mykyta Yatsenko
2026-06-05 11:41 ` [PATCH bpf-next v7 07/12] bpf: Optimize word-sized keys for resizable hashtable Mykyta Yatsenko
2026-06-05 11:54   ` sashiko-bot
2026-06-05 12:22   ` bot+bpf-ci
2026-06-05 11:41 ` [PATCH bpf-next v7 08/12] libbpf: Support " Mykyta Yatsenko
2026-06-05 11:41 ` [PATCH bpf-next v7 09/12] selftests/bpf: Add basic tests for resizable hash map Mykyta Yatsenko
2026-06-05 11:41 ` [PATCH bpf-next v7 10/12] selftests/bpf: Add BPF iterator " Mykyta Yatsenko
2026-06-05 11:56   ` sashiko-bot [this message]
2026-06-05 11:41 ` [PATCH bpf-next v7 11/12] bpftool: Add rhash map documentation Mykyta Yatsenko
2026-06-05 11:41 ` [PATCH bpf-next v7 12/12] selftests/bpf: Add resizable hashmap to benchmarks Mykyta Yatsenko
2026-06-05 12:03   ` sashiko-bot
2026-06-05 15:10 ` [PATCH bpf-next v7 00/12] bpf: Introduce resizable hash map 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=20260605115620.F1B7C1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=mykyta.yatsenko5@gmail.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 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.