From: sashiko-bot@kernel.org
To: chenyuan_fl@163.com
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf v4 1/2] bpf: Fix queue/stack map u32 index overflow
Date: Mon, 24 Aug 2026 08:47:03 +0000 [thread overview]
Message-ID: <20260824084704.174E21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260824083327.1708560-2-chenyuan_fl@163.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Kfuncs using enum parameters as array indices lack bounds checking for negative values.
--
--- Patch [1]: [PATCH bpf v4 1/2] bpf: Fix queue/stack map u32 index overflow ---
commit b3cc6df8f8f6a83f377bada50a4de0c2ebde4779
Author: Yuan Chen <chenyuan@kylinos.cn>
bpf: Fix queue/stack map u32 index overflow
This commit fixes an integer overflow in queue/stack maps by restoring a
bounds check in queue_stack_map_alloc_check(). It rejects max_entries and
value_size combinations that would reach or exceed U32_MAX bytes.
[ ... ]
While reviewing BPF bounds checking, I noticed a pre-existing issue in
mm/bpf_memcontrol.c:
> mm/bpf_memcontrol.c
>
> __bpf_kfunc unsigned long bpf_mem_cgroup_vm_events(struct mem_cgroup *memcg,
> enum vm_event_item event)
> {
> if (unlikely(!memcg_vm_event_item_valid(event)))
> return (unsigned long)-1;
[Severity: High]
This is a pre-existing issue, but since enums are represented as signed
integers in C, could a BPF program bypass this bounds check by passing a
negative enum value?
It appears that a negative event value could evade the upper bounds check
and lead to an out-of-bounds read when the event is used as an array index.
>
> return memcg_events(memcg, event);
> }
>
> ...
>
> __bpf_kfunc unsigned long bpf_mem_cgroup_memory_events(struct mem_cgroup *memcg,
> enum memcg_memory_event event)
> {
> if (unlikely(event >= MEMCG_NR_MEMORY_EVENTS))
> return (unsigned long)-1;
[Severity: High]
This isn't a bug introduced by this patch, but does this signed comparison
handle negative event values?
Similar to the above, a negative event value would pass this check and
subsequently be used as a negative index for the memory_events array.
Does this result in an out-of-bounds memory read?
>
> return atomic_long_read(&memcg->memory_events[event]);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260824083327.1708560-1-chenyuan_fl@163.com?part=1
next prev parent reply other threads:[~2026-08-24 8:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 13:59 [PATCH bpf v3 0/2] bpf: Fix queue/stack map u32 index overflow chenyuan_fl
2026-08-10 13:59 ` [PATCH bpf v3 1/2] " chenyuan_fl
2026-08-10 13:59 ` [PATCH bpf v3 2/2] selftests/bpf: Add regression test for queue/stack map size limit chenyuan_fl
2026-08-10 14:49 ` bot+bpf-ci
2026-08-13 22:19 ` Andrii Nakryiko
2026-08-24 8:33 ` [PATCH bpf v4 0/2] bpf: Fix queue/stack map u32 index overflow chenyuan_fl
2026-08-24 8:33 ` [PATCH bpf v4 1/2] " chenyuan_fl
2026-08-24 8:47 ` sashiko-bot [this message]
2026-08-28 0:04 ` Andrii Nakryiko
2026-08-31 6:32 ` [PATCH bpf v5 0/2] " chenyuan_fl
2026-08-31 6:32 ` [PATCH bpf v5 1/2] " chenyuan_fl
2026-08-31 7:13 ` bot+bpf-ci
2026-08-31 6:32 ` [PATCH bpf v5 2/2] selftests/bpf: Add regression test for queue/stack map size limit chenyuan_fl
2026-08-31 7:13 ` bot+bpf-ci
2026-09-02 23:30 ` [PATCH bpf v5 0/2] bpf: Fix queue/stack map u32 index overflow patchwork-bot+netdevbpf
2026-08-24 8:33 ` [PATCH bpf v4 2/2] selftests/bpf: Add regression test for queue/stack map size limit chenyuan_fl
2026-08-24 8:43 ` sashiko-bot
2026-08-24 9:25 ` bot+bpf-ci
2026-08-28 0:04 ` Andrii Nakryiko
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=20260824084704.174E21F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chenyuan_fl@163.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.