From: sashiko-bot@kernel.org
To: "Masoud Aghasi" <maghasi@disroot.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH 1/2] bpf: Fix incorrect handling of user flags by percpu map updates
Date: Mon, 28 Sep 2026 10:41:36 +0000 [thread overview]
Message-ID: <20260928104137.2B9601F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260928102821.995214-2-maghasi@disroot.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] bpf: bpf_percpu_array_update() misses validation for mutually exclusive flags
--
commit 41d85d3576867a24ad9b52f72cd4c1d7b23504a6
Author: Masoud Aghasi <maghasi@disroot.org>
bpf: Fix incorrect handling of user flags by percpu map updates
This commit fixes incorrect handling of BPF_EXIST, BPF_NOEXIST, BPF_F_CPU,
and BPF_F_ALL_CPUS flag combinations in BPF_MAP_TYPE_PERCPU_HASH and
BPF_MAP_TYPE_PERCPU_ARRAY map updates.
> diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
> index 0ce26b538075e..463f43b19e5cd 100644
> --- a/kernel/bpf/arraymap.c
> +++ b/kernel/bpf/arraymap.c
> @@ -438,7 +438,7 @@ int bpf_percpu_array_update(struct bpf_map *map, void *key, void *value,
> u32 size;
> int cpu, off = 0;
>
> - if (unlikely((map_flags & BPF_F_LOCK) || (u32)map_flags > BPF_F_ALL_CPUS))
> + if (unlikely((u32)map_flags & ~(BPF_EXIST | BPF_NOEXIST | BPF_F_CPU | BPF_F_ALL_CPUS)))
> /* unknown flags */
> return -EINVAL;
>
> @@ -446,7 +446,7 @@ int bpf_percpu_array_update(struct bpf_map *map, void *key, void *value,
> /* all elements were pre-allocated, cannot insert a new one */
> return -E2BIG;
>
> - if (unlikely(map_flags == BPF_NOEXIST))
> + if (unlikely(map_flags & BPF_NOEXIST))
[Severity: Low]
Does this validation correctly handle the case where both BPF_EXIST and
BPF_NOEXIST are passed together?
Since the mask check above allows this mutually exclusive combination through,
evaluating `map_flags & BPF_NOEXIST` as true here will return -EEXIST instead
of the expected -EINVAL error code. Should an explicit check for the
combination of BPF_EXIST and BPF_NOEXIST be added here, similar to the one
added for hash maps in htab_map_check_update_flags() in this same patch?
> /* all elements already exist */
> return -EEXIST;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260928102821.995214-1-maghasi@disroot.org?part=1
next prev parent reply other threads:[~2026-09-28 10:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 10:28 [PATCH 0/2] bpf: Fix incorrect handling of user flags by percpu map updates Masoud Aghasi
2026-09-28 10:28 ` [PATCH 1/2] " Masoud Aghasi
2026-09-28 10:41 ` sashiko-bot [this message]
2026-09-28 12:53 ` Masoud Aghasi
2026-09-28 10:28 ` [PATCH 2/2] selftests/bpf: add test for percpu map flags combination Masoud Aghasi
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=20260928104137.2B9601F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=maghasi@disroot.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox