BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Daniel Borkmann" <daniel@iogearbox.net>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 4/4] bpf: Account scratch buffer in bpf_prog_calc_tag
Date: Wed, 08 Jul 2026 21:25:43 +0000	[thread overview]
Message-ID: <20260708212544.48E431F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260708211537.371874-5-daniel@iogearbox.net>

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

Pre-existing issues:
- [Medium] Missing memcg accounting for the temporary JIT scratch buffer `rw_header`.
--

--- Patch [4]: [PATCH bpf-next 4/4] bpf: Account scratch buffer in bpf_prog_calc_tag ---
commit 57c46cbb1e055c7c0a73414dd57ed04bc1cb8b73
Author: Daniel Borkmann <daniel@iogearbox.net>

bpf: Account scratch buffer in bpf_prog_calc_tag

This commit updates bpf_prog_calc_tag() to use GFP_KERNEL_ACCOUNT for its
vmalloc scratch buffer. This ensures the temporary memory, which scales with
the program size, is properly charged to the loader's memory cgroup.

> diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
> --- a/kernel/bpf/core.c
> +++ b/kernel/bpf/core.c
> @@ -305,7 +305,7 @@ int bpf_prog_calc_tag(struct bpf_prog *fp)
>  	bool was_ld_map;
>  	u32 i;
>  
> -	dst = vmalloc(size);
> +	dst = __vmalloc(size, GFP_KERNEL_ACCOUNT);

[Severity: Medium]
This is a pre-existing issue, but since this patch correctly applies memcg
accounting to load-time scratch memory, should we also account the
temporary JIT scratch buffer?

Looking at bpf_jit_binary_pack_alloc() in the same file, rw_header scales
with the program size but uses GFP_KERNEL instead of GFP_KERNEL_ACCOUNT:

kernel/bpf/core.c:bpf_jit_binary_pack_alloc() {
    ...
    *rw_header = kvmalloc(size, GFP_KERNEL);
    ...
}

Does this missing accounting allow a process to bypass its memcg limits by
triggering concurrent JIT compilations?

>  	if (!dst)
>  		return -ENOMEM;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260708211537.371874-1-daniel@iogearbox.net?part=4

  reply	other threads:[~2026-07-08 21:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08 21:15 [PATCH bpf-next 0/4] Misc BPF fixes from sashiko findings Daniel Borkmann
2026-07-08 21:15 ` [PATCH bpf-next 1/4] bpf: Fix vmlinux BTF prep race in bpf_get_btf_vmlinux Daniel Borkmann
2026-07-08 22:17   ` bot+bpf-ci
2026-07-08 21:15 ` [PATCH bpf-next 2/4] bpf: Give vmlinux BTF init its own mutex Daniel Borkmann
2026-07-08 21:15 ` [PATCH bpf-next 3/4] bpf: Account insn_aux_data allocation in bpf_check Daniel Borkmann
2026-07-08 21:15 ` [PATCH bpf-next 4/4] bpf: Account scratch buffer in bpf_prog_calc_tag Daniel Borkmann
2026-07-08 21:25   ` sashiko-bot [this message]
2026-07-09  5:10 ` [PATCH bpf-next 0/4] Misc BPF fixes from sashiko findings patchwork-bot+netdevbpf

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=20260708212544.48E431F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --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