From: sashiko-bot@kernel.org
To: "Pu Lehui" <pulehui@huaweicloud.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 7/9] bpf, arm64: Fix private stack leak when JIT failed
Date: Sat, 25 Jul 2026 15:55:34 +0000 [thread overview]
Message-ID: <20260725155535.0398E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260725154915.2488611-8-pulehui@huaweicloud.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Medium] Memory leak of the BPF private stack in the PowerPC JIT compiler upon JIT failure.
--
--- Patch [7]: [PATCH bpf-next v3 7/9] bpf, arm64: Fix private stack leak when JIT failed ---
commit 8de8b0f7fc232dba7540d3099301a4c55f3544c0
Author: Pu Lehui <pulehui@huawei.com>
bpf, arm64: Fix private stack leak when JIT failed
This patch fixes a memory leak in the ARM64 BPF JIT compiler. When JIT
compilation fails, the private stack percpu memory was being leaked because
the cleanup check evaluated to false after a pointer was left dangling. The
fix sets the pointer to NULL to ensure proper cleanup.
> diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> index f4e4d4578e38a..6e036acf80d8b 100644
> --- a/arch/arm64/net/bpf_jit_comp.c
> +++ b/arch/arm64/net/bpf_jit_comp.c
> @@ -2311,6 +2311,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr
> bpf_arch_text_copy(&ro_header->size, &header->size,
> sizeof(header->size));
> bpf_jit_binary_pack_free(ro_header, header);
> + ro_header = NULL;
[Severity: Medium]
This is a pre-existing issue, but while fixing this memory leak for arm64,
it appears that the PowerPC JIT compiler has the exact same problem.
In arch/powerpc/net/bpf_jit_comp.c:bpf_int_jit_compile():
if (bpf_jit_build_body(fp, code_base, fcode_base, &cgctx, addrs, pass,
extra_pass)) {
bpf_arch_text_copy(&fhdr->size, &hdr->size, sizeof(hdr->size));
bpf_jit_binary_pack_free(fhdr, hdr);
goto out_err;
}
When jumping to the error cleanup path, the JIT binary is freed but the image
pointer remains non-NULL.
Then in the cleanup path:
out_addrs:
if (!image && priv_stack_ptr) {
fp->aux->priv_stack_ptr = NULL;
free_percpu(priv_stack_ptr);
}
Because the image pointer is still non-NULL, this check evaluates to false.
Can this also cause the private stack percpu memory to be leaked in the
PowerPC JIT? Should a similar fix be applied there?
> }
> goto out_off;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260725154915.2488611-1-pulehui@huaweicloud.com?part=7
next prev parent reply other threads:[~2026-07-25 15:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-25 15:49 [PATCH bpf-next v3 0/9] Fixes for bpf_jit_free Pu Lehui
2026-07-25 15:49 ` [PATCH bpf-next v3 1/9] bpf: Extract the bpf_jit_binary_hdr helper Pu Lehui
2026-07-25 15:49 ` [PATCH bpf-next v3 2/9] s390/bpf: Fix memory leak in bpf_jit_free Pu Lehui
2026-07-25 15:49 ` [PATCH bpf-next v3 3/9] parisc: " Pu Lehui
2026-07-25 15:54 ` sashiko-bot
2026-07-25 15:49 ` [PATCH bpf-next v3 4/9] bpf, sparc64: " Pu Lehui
2026-07-25 15:49 ` [PATCH bpf-next v3 5/9] ARC, bpf: " Pu Lehui
2026-07-25 15:49 ` [PATCH bpf-next v3 6/9] bpf, arm64: " Pu Lehui
2026-07-25 16:01 ` sashiko-bot
2026-07-25 15:49 ` [PATCH bpf-next v3 7/9] bpf, arm64: Fix private stack leak when JIT failed Pu Lehui
2026-07-25 15:55 ` sashiko-bot [this message]
2026-07-25 15:49 ` [PATCH bpf-next v3 8/9] riscv, bpf: Adjust bpf_func to account for CFI offset in bpf_jit_free Pu Lehui
2026-07-25 15:57 ` sashiko-bot
2026-07-25 15:49 ` [PATCH bpf-next v3 9/9] bpf: Fix double-free RO header " Pu Lehui
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=20260725155535.0398E1F000E9@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.