From: sashiko-bot@kernel.org
To: "Pu Lehui" <pulehui@huaweicloud.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 1/4] bpf, arm64: Fix memory leak in bpf_jit_free
Date: Wed, 22 Jul 2026 11:38:08 +0000 [thread overview]
Message-ID: <20260722113808.94D6D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260722112754.1615201-2-pulehui@huaweicloud.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Memory leak of `jit_data->ctx.offset` in `bpf_jit_free()` for the LoongArch architecture.
--
--- Patch [1]: [PATCH bpf-next 1/4] bpf, arm64: Fix memory leak in bpf_jit_free ---
commit 34ee740bc2723be0c26671951b05fa73e1bfc918
Author: Pu Lehui <pulehui@huawei.com>
bpf, arm64: Fix memory leak in bpf_jit_free
This commit fixes a memory leak in the ARM64 BPF JIT compiler. When
bpf_jit_free() cleans up a subprogram after a later subprogram fails JIT
compilation, it now correctly frees the jit_data->ctx.offset array.
> diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> index 4cdc7dfb05ba9..f4e4d4578e38a 100644
> --- a/arch/arm64/net/bpf_jit_comp.c
> +++ b/arch/arm64/net/bpf_jit_comp.c
> @@ -3237,6 +3237,7 @@ void bpf_jit_free(struct bpf_prog *prog)
> */
> if (jit_data) {
> bpf_jit_binary_pack_finalize(jit_data->ro_header, jit_data->header);
> + kvfree(jit_data->ctx.offset);
[Severity: High]
This isn't a bug introduced by this patch, but does the same memory leak
exist in the LoongArch BPF JIT compiler?
Looking at arch/loongarch/net/bpf_jit.c in bpf_jit_free():
if (jit_data) {
bpf_jit_binary_pack_finalize(jit_data->ro_header, jit_data->header);
kfree(jit_data);
}
It appears jit_data->ctx.offset is not freed there before kfree(jit_data)
is called.
Could this lead to a similar resource leak if userspace loads a BPF program
with multiple subprograms that passes verification but fails JIT compilation?
> kfree(jit_data);
> }
> prog->bpf_func = (void *)prog->bpf_func - cfi_get_offset();
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260722112754.1615201-1-pulehui@huaweicloud.com?part=1
next prev parent reply other threads:[~2026-07-22 11:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 11:27 [PATCH bpf-next 0/4] Fixes for bpf_jit_free Pu Lehui
2026-07-22 11:27 ` [PATCH bpf-next 1/4] bpf, arm64: Fix memory leak in bpf_jit_free Pu Lehui
2026-07-22 11:38 ` sashiko-bot [this message]
2026-07-22 11:27 ` [PATCH bpf-next 2/4] LoongArch: BPF: " Pu Lehui
2026-07-22 11:35 ` sashiko-bot
2026-07-22 11:27 ` [PATCH bpf-next 3/4] riscv, bpf: Adjust bpf_func to account for CFI offset " Pu Lehui
2026-07-22 11:38 ` sashiko-bot
2026-07-22 11:27 ` [PATCH bpf-next 4/4] bpf: Fix double-free RO header " Pu Lehui
2026-07-22 11:33 ` sashiko-bot
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=20260722113808.94D6D1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=pulehui@huaweicloud.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.