From: sashiko-bot@kernel.org
To: "Leon Hwang" <leon.hwang@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v5 5/9] bpftool: Generate skeleton for global percpu data
Date: Mon, 08 Jun 2026 15:11:09 +0000 [thread overview]
Message-ID: <20260608151109.D0A701F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260608145113.65857-6-leon.hwang@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Exposing `.percpu` maps via `skel->percpu` in generated skeletons introduces severe abstraction violations: silent write failures in Light Skeletons and stale data reads in Subskeletons.
--
commit 8d5ae684c03b8ed70309315b60b9b65b471e24bd
Author: Leon Hwang <leon.hwang@linux.dev>
bpftool: Generate skeleton for global percpu data
This patch enhances bpftool to generate skeletons that properly handle global
percpu variables. The generated skeleton includes a dedicated nested structure
for percpu data, allowing easier initialization.
> diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
> index 6ae7262ebe0c1..e0c5c643fe9ea 100644
> --- a/tools/bpf/bpftool/gen.c
> +++ b/tools/bpf/bpftool/gen.c
[ ... ]
> @@ -263,13 +268,12 @@ static bool is_mmapable_map(const struct bpf_map *map, char *buf, size_t sz)
> return true;
> }
>
> - if (!bpf_map__is_internal(map) || !(bpf_map__map_flags(map) & BPF_F_MMAPABLE))
> - return false;
> -
> - if (!get_map_ident(map, buf, sz))
> - return false;
> + if (bpf_map__is_internal(map) &&
> + ((bpf_map__map_flags(map) & BPF_F_MMAPABLE) || bpf_map_is_percpu_data(map)) &&
> + get_map_ident(map, buf, sz))
> + return true;
>
> - return true;
> + return false;
> }
[Severity: High]
Does forcibly treating the percpu maps as mmapable here break subskeletons?
Since subskeletons operate on an already-loaded BPF object to read or write
live state, this change might cause do_subskeleton() to export pointers to
disconnected user-space memory.
If they point to the disconnected PROT_READ initialization buffer instead of
live state, would reads always return stale initial data and fail to reflect
live kernel modifications?
[ ... ]
> @@ -847,7 +851,7 @@ static int gen_trace(struct bpf_object *obj, const char *obj_name, const char *h
> bpf_object__for_each_map(map, obj) {
> const char *mmap_flags;
>
> - if (!is_mmapable_map(map, ident, sizeof(ident)))
> + if (!is_mmapable_map(map, ident, sizeof(ident)) || bpf_map_is_percpu_data(map))
> continue;
>
> if (bpf_map__map_flags(map) & BPF_F_RDONLY_PROG)
[Severity: High]
Does skipping map finalization for percpu maps in light skeletons leave the
user-space initialization buffer mapped as PROT_READ | PROT_WRITE?
In standard skeletons managed by libbpf, the buffer is protected with
PROT_READ to explicitly crash on invalid writes.
If we skip finalization here in gen_trace(), it seems writes to lskel->percpu
after load() might silently succeed without actually updating the kernel map.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260608145113.65857-1-leon.hwang@linux.dev?part=5
next prev parent reply other threads:[~2026-06-08 15:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 14:51 [PATCH bpf-next v5 0/9] bpf: Introduce global percpu data Leon Hwang
2026-06-08 14:51 ` [PATCH bpf-next v5 1/9] bpf: Drop duplicate blank lines in verifier Leon Hwang
2026-06-08 14:51 ` [PATCH bpf-next v5 2/9] bpf: Introduce global percpu data Leon Hwang
2026-06-08 15:13 ` sashiko-bot
2026-06-08 15:56 ` bot+bpf-ci
2026-06-08 14:51 ` [PATCH bpf-next v5 3/9] libbpf: Probe percpu data feature Leon Hwang
2026-06-08 15:05 ` sashiko-bot
2026-06-08 14:51 ` [PATCH bpf-next v5 4/9] libbpf: Add support for global percpu data Leon Hwang
2026-06-08 14:51 ` [PATCH bpf-next v5 5/9] bpftool: Generate skeleton " Leon Hwang
2026-06-08 15:11 ` sashiko-bot [this message]
2026-06-08 15:29 ` bot+bpf-ci
2026-06-08 14:51 ` [PATCH bpf-next v5 6/9] selftests/bpf: Add tests to verify " Leon Hwang
2026-06-08 15:20 ` sashiko-bot
2026-06-08 14:51 ` [PATCH bpf-next v5 7/9] selftests/bpf: Add tests to verify verifier log for " Leon Hwang
2026-06-08 15:22 ` sashiko-bot
2026-06-08 14:51 ` [PATCH bpf-next v5 8/9] selftests/bpf: Add test to verify xlated insns " Leon Hwang
2026-06-08 15:21 ` sashiko-bot
2026-06-08 14:51 ` [PATCH bpf-next v5 9/9] selftests/bpf: Add test to verify bpf_iter " Leon Hwang
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=20260608151109.D0A701F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=leon.hwang@linux.dev \
--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