All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Leon Hwang" <leon.hwang@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v9 5/9] bpftool: Generate skeleton for global percpu data
Date: Mon, 13 Jul 2026 16:48:23 +0000	[thread overview]
Message-ID: <20260713164824.46FA71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260713154024.30851-6-leon.hwang@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] In light skeletons, `BPF_MAP_TYPE_ARENA` maps with initial values are permanently leaked because `__destroy()` skips them, failing to unmap their memory.
--

--- Patch [5]: [PATCH bpf-next v9 5/9] bpftool: Generate skeleton for global percpu data ---
commit b822b756947c191db53a46cfd85674008d72587c
Author: Leon Hwang <leon.hwang@linux.dev>

bpftool: Generate skeleton for global percpu data

Enhance bpftool to generate skeletons that properly handle global percpu
variables. The generated skeleton now includes a dedicated structure for
percpu data, allowing users to initialize and access percpu variables more
efficiently.

> diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
> index a01d06d22d1a3..b60db11081497 100644
> --- a/tools/bpf/bpftool/gen.c
> +++ b/tools/bpf/bpftool/gen.c

[ ... ]

> @@ -669,7 +693,8 @@ static void codegen_destroy(struct bpf_object *obj, const char *obj_name)
>  		if (!get_map_ident(map, ident, sizeof(ident)))
>  			continue;
>  		if (bpf_map__is_internal(map) &&
> -		    (bpf_map__map_flags(map) & BPF_F_MMAPABLE))
> +		    ((bpf_map__map_flags(map) & BPF_F_MMAPABLE) ||
> +		     bpf_map__type(map) == BPF_MAP_TYPE_PERCPU_ARRAY))
>  			printf("\tskel_free_map_data(skel->%1$s, skel->maps.%1$s.initial_value, %2$zu);\n",
>  			       ident, bpf_map_mmap_sz(map));

[Severity: High]
This is a pre-existing issue, but does this manual internal map check cause
BPF_MAP_TYPE_ARENA maps to be permanently leaked in light skeletons?

ARENA maps with initial values appear to be skipped here because
bpf_map__is_internal() evaluates to false for them. This skips the generation
of the skel_free_map_data() call.

Since ARENA maps can be very large, skipping them during skeleton destruction
leaks both the userspace virtual memory (VMA) and the underlying kernel
bpf_map object, as the VMA holds a file reference to it. This can lead to
resource exhaustion if a daemon repeatedly reloads BPF policies.

Could this code be updated to use is_skel_data() instead of get_map_ident()
and bpf_map__is_internal() so that ARENA map memory is correctly unmapped and
freed?

>  		codegen("\

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260713154024.30851-1-leon.hwang@linux.dev?part=5

  reply	other threads:[~2026-07-13 16:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13 15:40 [PATCH bpf-next v9 0/9] bpf: Introduce global percpu data Leon Hwang
2026-07-13 15:40 ` [PATCH bpf-next v9 1/9] bpf: Drop duplicate blank lines in verifier Leon Hwang
2026-07-13 15:40 ` [PATCH bpf-next v9 2/9] bpf: Introduce global percpu data Leon Hwang
2026-07-13 15:40 ` [PATCH bpf-next v9 3/9] libbpf: Probe percpu data feature Leon Hwang
2026-07-13 16:17   ` sashiko-bot
2026-07-14  1:42     ` Leon Hwang
2026-07-13 15:40 ` [PATCH bpf-next v9 4/9] libbpf: Add support for global percpu data Leon Hwang
2026-07-13 15:40 ` [PATCH bpf-next v9 5/9] bpftool: Generate skeleton " Leon Hwang
2026-07-13 16:48   ` sashiko-bot [this message]
2026-07-14  5:45     ` Leon Hwang
2026-07-13 15:40 ` [PATCH bpf-next v9 6/9] selftests/bpf: Add tests to verify " Leon Hwang
2026-07-13 17:13   ` sashiko-bot
2026-07-14  1:51     ` Leon Hwang
2026-07-13 15:40 ` [PATCH bpf-next v9 7/9] selftests/bpf: Test direct reading/writing read-only percpu_array map Leon Hwang
2026-07-13 15:40 ` [PATCH bpf-next v9 8/9] selftests/bpf: Test verifier log for global percpu data Leon Hwang
2026-07-13 15:40 ` [PATCH bpf-next v9 9/9] selftests/bpf: 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=20260713164824.46FA71F000E9@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 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.