From: bot+bpf-ci@kernel.org
To: chenyuan_fl@163.com,bpf@vger.kernel.org
Cc: ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,chenyuan@kylinos.cn,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,clm@meta.com,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf v2 2/2] selftests/bpf: Add regression test for queue/stack map size limit
Date: Mon, 10 Aug 2026 10:28:49 +0000 (UTC) [thread overview]
Message-ID: <86fd4df54c74ea4deab367b47e594137099eb29d0452bca1f2a3d4d393df210d@mail.kernel.org> (raw)
In-Reply-To: <20260810092814.2698521-3-chenyuan_fl@163.com>
[-- Attachment #1: Type: text/plain, Size: 3348 bytes --]
> 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 41441325e179..8ab07ea77775 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,53 @@ 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:
> + * 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);
> + saved_errno = errno;
> + ASSERT_LT(fd, 0, "queue_oversize_fd");
> + ASSERT_EQ(saved_errno, E2BIG, "queue_oversize_errno");
> +
> + /*
> + * max_entries == U32_MAX would make the u32 capacity counter
> + * qs->size (max_entries + 1) wrap to 0, permanently breaking the
> + * map, so it must be rejected as well.
> + */
> + fd = bpf_map_create(BPF_MAP_TYPE_QUEUE, NULL, 0, 1, U32_MAX, &opts);
^^^^^^^
Does this build? U32_MAX is not defined in any header reachable from this
file.
U32_MAX exists only in include/linux/limits.h in the kernel tree, which is
not part of include/uapi/ and has no copy under tools/include/. The BPF
selftests include closure (test_progs.h and its dependencies) does not
provide this macro. libc provides UINT_MAX and UINT32_MAX, but not U32_MAX.
Existing selftests that need U32_MAX define it locally. In the same
directory, prog_tests/reg_bounds.c does:
#define U32_MAX ((u32)UINT_MAX)
Since the BPF selftests Makefile builds with -Wall -Werror and every
prog_tests/*.c is linked into the single test_progs binary, this breaks the
entire selftest build rather than just this subtest.
Should this either define the macro locally (as reg_bounds.c does) or use
UINT_MAX from <limits.h>?
> + saved_errno = errno;
> + ASSERT_LT(fd, 0, "queue_u32max_fd");
> + ASSERT_EQ(saved_errno, E2BIG, "queue_u32max_errno");
> + if (fd >= 0)
> + close(fd);
> +
> + fd = bpf_map_create(BPF_MAP_TYPE_STACK, NULL, 0, big_value, 8192, &opts);
> + saved_errno = errno;
> + ASSERT_LT(fd, 0, "stack_oversize_fd");
> + ASSERT_EQ(saved_errno, E2BIG, "stack_oversize_errno");
> + if (fd >= 0)
> + close(fd);
> +
> + /* A normal-sized map must still be created successfully. */
> + fd = bpf_map_create(BPF_MAP_TYPE_QUEUE, NULL, 0, 64, 100, &opts);
> + ASSERT_GE(fd, 0, "queue_normal_fd");
> + if (fd >= 0)
> + close(fd);
> +}
> +
> void test_queue_stack_map(void)
> {
> test_queue_stack_map_by_type(QUEUE);
> test_queue_stack_map_by_type(STACK);
> + test_queue_stack_map_alloc_check();
> }
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/31375986836
prev parent reply other threads:[~2026-08-10 10:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 9:28 [PATCH bpf v2 0/2] bpf: Fix queue/stack map u32 index overflow chenyuan_fl
2026-08-10 9:28 ` [PATCH bpf v2 1/2] " chenyuan_fl
2026-08-10 10:28 ` bot+bpf-ci
2026-08-13 22:16 ` Andrii Nakryiko
2026-08-10 9:28 ` [PATCH bpf v2 2/2] selftests/bpf: Add regression test for queue/stack map size limit chenyuan_fl
2026-08-10 9:39 ` sashiko-bot
2026-08-10 10:28 ` bot+bpf-ci [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=86fd4df54c74ea4deab367b47e594137099eb29d0452bca1f2a3d4d393df210d@mail.kernel.org \
--to=bot+bpf-ci@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chenyuan@kylinos.cn \
--cc=chenyuan_fl@163.com \
--cc=clm@meta.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=martin.lau@kernel.org \
--cc=yonghong.song@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