Re: [PATCH 2/2] selftests/bpf: Add regression test for queue/stack map size limit

[email protected]
Newsgroups org.kernel.vger.bpf
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Multi-line comment opening `/*` is not on its own line.
--

--- Patch [2]: [PATCH 2/2] selftests/bpf: Add regression test for queue/stack map size limit ---
commit e79d16bed784907a39f11792c9c1497efb8fd26f
Author: Yuan Chen <[email protected]>

selftests/bpf: Add regression test for queue/stack map size limit

This commit adds a regression test to verify that queue and stack maps reject
creation if their element storage size exceeds U32_MAX bytes. It tests both
queue and stack maps with an oversized configuration, ensuring they fail with
-E2BIG, and also verifies that a normal-sized map is successfully created.

> diff --git a/tools/testing/selftests/bpf/prog_tests/queue_stack_map.c b/tools/testing/selftests/bpf/prog_tests/queue_stack_map.c
> index 41441325e1794..6f8ac285e7196 100644
> --- a/tools/testing/selftests/bpf/prog_tests/queue_stack_map.c
> +++ b/tools/testing/selftests/bpf/prog_tests/queue_stack_map.c
[ ... ]
> @@ -101,8 +101,42 @@ static void test_queue_stack_map_by_type(int type)
>  	bpf_object__close(obj);
>  }
>  
> +static void test_queue_stack_map_alloc_check(void)
> +{
> +	LIBBPF_OPTS(bpf_map_create_opts, opts);
> +	const __u32 big_value = 1 << 20; /* 1MB */
> +	int fd, saved_errno;
> +
> +	/* Regression test for the u32 index overflow in queue/stack maps:

[Severity: Low]
This isn't a bug, but should this multi-line comment follow the BPF subsystem
comment style by placing the opening /* on its own line?

> +	 * a map whose element storage (max_entries * value_size) exceeds
> +	 * U32_MAX bytes must be rejected at creation time, otherwise the
> +	 * u32 head/tail index multiplication wraps and push/peek/pop
> +	 * address the wrong element. 8192 * 1MB = 8GB > U32_MAX.
> +	 */
> +	fd = bpf_map_create(BPF_MAP_TYPE_QUEUE, NULL, 0, big_value, 8192, &opts);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.