All of lore.kernel.org
 help / color / mirror / Atom feed
From: R Nageswara Sastry <rnsastry@linux.ibm.com>
To: Saket Kumar Bhaskar <skb99@linux.ibm.com>,
	bpf@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Cc: hbathini@linux.ibm.com, maddy@linux.ibm.com, ast@kernel.org,
	andrii@kernel.org, daniel@iogearbox.net, shuah@kernel.org,
	linux-kselftest@vger.kernel.org, stable@vger.kernel.org,
	venkat88@linux.ibm.com, yeswanth@linux.ibm.com
Subject: Re: [PATCH v13 2/8] powerpc64/bpf: fix percpu private stack leak on JIT failure
Date: Tue, 8 Sep 2026 22:01:20 +0530	[thread overview]
Message-ID: <ffecf223-fe43-462c-9f20-4128f762c90e@linux.ibm.com> (raw)
In-Reply-To: <a827e3ef81cd43f2aee7e9bdfe8683f2c77065da.1788154635.git.skb99@linux.ibm.com>


On 31.08.2026 12:45 PM, Saket Kumar Bhaskar wrote:
> From: Abhishek Dubey <adubey@linux.ibm.com>
>
> The existing conditional statement in bpf_int_jit_compile() frees the
> percpu private stack at out_addrs only when the image buffer was never
> allocated.
>
> If bpf_jit_build_body() fails during a code-generation pass, the
> image buffer has already been allocated, so !image is false and the
> percpu stack is not freed.
>
> Because JIT compilation failed, fp->jited remains at 0. The subsequent
> bpf_jit_free() path only frees priv_stack_ptr when fp->jited is set, so
> freeing is skipped here too, leaking the percpu allocation.
>
> Fix implements freeing the private stack whenever fp->jited was not set,
> i.e. compilation did not succeed, instead of keying off !image. !fp->jited
> already covers the !image case, since image is only NULL on early-failure
> paths where fp->jited is likewise 0.
>
> Reported-by: sashiko-bot@kernel.org
> Closes: https://lore.kernel.org/bpf/20260616135426.A06B71F000E9@smtp.kernel.org
> Fixes: 156d985123b6 ("powerpc64/bpf: Implement JIT support for private stack")
> Cc: stable@vger.kernel.org
> Signed-off-by: Abhishek Dubey <adubey@linux.ibm.com>
> Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
> Tested-by: Yeswanth Krishna Tellakula <yeswanth@linux.ibm.com>
> Acked-by: Hari Bathini <hbathini@linux.ibm.com>
Tested-by: R Nageswara Sastry <rnsastry@linux.ibm.com>

System: ppc64le LPAR (IBM POWER), Linux 7.3-rc2
> ---
>   arch/powerpc/net/bpf_jit_comp.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
> index a875521ff904..8f7501954d9f 100644
> --- a/arch/powerpc/net/bpf_jit_comp.c
> +++ b/arch/powerpc/net/bpf_jit_comp.c
> @@ -357,7 +357,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr
>   				(void *)fimage + FUNCTION_DESCR_SIZE);
>   
>   out_addrs:
> -		if (!image && priv_stack_ptr) {
> +		if (!fp->jited && priv_stack_ptr) {
>   			fp->aux->priv_stack_ptr = NULL;
>   			free_percpu(priv_stack_ptr);
>   		}

-- 
Thanks and Regards
R.Nageswara Sastry


  parent reply	other threads:[~2026-09-08 16:31 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31  7:15 [PATCH v13 0/8] powerpc/bpf: address missing verifier selftest coverage Saket Kumar Bhaskar
2026-08-31  7:15 ` [PATCH v13 1/8] powerpc64/bpf: fix compare instruction emitted for tailcall Saket Kumar Bhaskar
2026-09-08 16:30   ` R Nageswara Sastry
2026-08-31  7:15 ` [PATCH v13 2/8] powerpc64/bpf: fix percpu private stack leak on JIT failure Saket Kumar Bhaskar
2026-08-31  7:32   ` sashiko-bot
2026-09-08 16:31   ` R Nageswara Sastry [this message]
2026-08-31  7:16 ` [PATCH v13 3/8] powerpc/bpf: fix buffer overflow in JIT for large BPF programs Saket Kumar Bhaskar
2026-08-31  8:24   ` bot+bpf-ci
2026-09-08  8:48     ` Hari Bathini
2026-09-08 16:31   ` R Nageswara Sastry
2026-08-31  7:16 ` [PATCH v13 4/8] powerpc/bpf: fix alignment of long branch trampoline address Saket Kumar Bhaskar
2026-08-31  8:12   ` bot+bpf-ci
2026-09-08  8:23     ` Hari Bathini
2026-09-08  8:35       ` Hari Bathini
2026-09-08 16:32   ` R Nageswara Sastry
2026-08-31  7:16 ` [PATCH v13 5/8] powerpc/bpf: Move out dummy_tramp_addr after Long branch stub Saket Kumar Bhaskar
2026-08-31  7:35   ` sashiko-bot
2026-09-08  8:46   ` Hari Bathini
2026-09-08 16:32   ` R Nageswara Sastry
2026-08-31  7:16 ` [PATCH v13 6/8] selftests/bpf: Fix powerpc JIT disassembly failure Saket Kumar Bhaskar
2026-08-31  8:12   ` bot+bpf-ci
2026-09-08 16:33   ` R Nageswara Sastry
2026-08-31  7:16 ` [PATCH v13 7/8] selftests/bpf: Enable verifier selftest for powerpc64 Saket Kumar Bhaskar
2026-09-08 16:33   ` R Nageswara Sastry
2026-08-31  7:16 ` [PATCH v13 8/8] selftests/bpf: Add tailcall " Saket Kumar Bhaskar
2026-08-31  8:12   ` bot+bpf-ci
2026-09-08 16:33   ` R Nageswara Sastry

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=ffecf223-fe43-462c-9f20-4128f762c90e@linux.ibm.com \
    --to=rnsastry@linux.ibm.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=hbathini@linux.ibm.com \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=shuah@kernel.org \
    --cc=skb99@linux.ibm.com \
    --cc=stable@vger.kernel.org \
    --cc=venkat88@linux.ibm.com \
    --cc=yeswanth@linux.ibm.com \
    /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.