From: chenyuan_fl@163.com
To: bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Yuan Chen <chenyuan@kylinos.cn>
Subject: [PATCH bpf v2 0/2] bpf: Fix queue/stack map u32 index overflow
Date: Mon, 10 Aug 2026 17:28:12 +0800 [thread overview]
Message-ID: <20260810092814.2698521-1-chenyuan_fl@163.com> (raw)
From: Yuan Chen <chenyuan@kylinos.cn>
The queue/stack map addresses elements[] with the product of a u32
head/tail index and value_size, but the storage itself is allocated in
64-bit arithmetic. When max_entries * value_size exceeds U32_MAX, the
product wraps and push/peek/pop operate on the wrong element. Patch 1
restores the dropped bound check; patch 2 adds a regression test.
Changes in v2:
- Also reject max_entries == U32_MAX: the u32 capacity counter
qs->size (max_entries + 1) would wrap to 0 and permanently break
the map, as pointed out in review.
- Fix the multi-line comment style in the selftest, as pointed out in
review.
Yuan Chen (2):
bpf: Fix queue/stack map u32 index overflow
selftests/bpf: Add regression test for queue/stack map size limit
kernel/bpf/queue_stack_maps.c | 10 +++++
.../bpf/prog_tests/queue_stack_map.c | 45 +++++++++++++++++++
2 files changed, 55 insertions(+)
--
2.54.0
next reply other threads:[~2026-08-10 9:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 9:28 chenyuan_fl [this message]
2026-08-10 9:28 ` [PATCH bpf v2 1/2] bpf: Fix queue/stack map u32 index overflow 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
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=20260810092814.2698521-1-chenyuan_fl@163.com \
--to=chenyuan_fl@163.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chenyuan@kylinos.cn \
--cc=daniel@iogearbox.net \
/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