BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Saket Kumar Bhaskar" <skb99@linux.ibm.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v11 7/8] powerpc/bpf: fix buffer overflow in JIT for large BPF programs
Date: Fri, 07 Aug 2026 12:41:58 +0000	[thread overview]
Message-ID: <20260807124159.4E3461F000E9@smtp.kernel.org> (raw)
In-Reply-To: <8c6611f4244c448766d04e90f8ea07bb1dd22dd8.1786099877.git.skb99@linux.ibm.com>

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

Pre-existing issues:
- [High] Silent branch offset truncation in exception table fixup generation.
--

--- Patch [7]: [PATCH v11 7/8] powerpc/bpf: fix buffer overflow in JIT for large BPF programs ---
commit 575dc92c1d10e63b9fc1ecf052e4cace5279974f
Author: Abhishek Dubey <adubey@linux.ibm.com>
Subject: powerpc/bpf: fix buffer overflow in JIT for large BPF programs

This commit fixes a buffer overflow during JIT compilation of large BPF
programs on PowerPC. It addresses an issue where the exit address was
unpopulated in the first pass, skipping the epilogue size calculation and
causing a buffer overflow in subsequent passes when the real exit address
required a full inline epilogue. The patch updates the multi-pass logic to
loop until the program size converges.

Link: https://lore.kernel.org/bpf/20260529015855.364704-2-adubey@linux.ibm.com/T/#mfcb23909d977b949727cca4f59ee56a13fd69b92

> diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
> index 757b36bfbac35..2cc1124ed5303 100644
> --- a/arch/powerpc/net/bpf_jit_comp.c
> +++ b/arch/powerpc/net/bpf_jit_comp.c

[ ... ]

> @@ -428,7 +446,7 @@ int bpf_add_extable_entry(struct bpf_prog *fp, u32 *image, u32 *fimage, int pass
>  	u32 *fixup;
>  
>  	/* Populate extable entries only in the last pass */
> -	if (pass != 2)
> +	if (pass < CODEGEN_MIN_PASSES)
>  		return 0;
>  
>  	if (!fp->aux->extable ||

[Severity: High]
This is a pre-existing issue, but since this patch explicitly targets
support for large BPF programs (exceeding the 32MB branch range), does the
exception table fixup generation also need an out-of-range branch check?

Looking at bpf_add_extable_entry() just below this hunk:

    fixup[BPF_FIXUP_LEN - 1] =
        PPC_RAW_BRANCH((long)(pc + jmp_off) - (long)&fixup[BPF_FIXUP_LEN - 1]);

Since PPC_RAW_BRANCH silently masks out-of-range offsets without returning
an error (unlike PPC_JMP which uses is_offset_in_branch_range()), could a
large BPF program with exception handlers result in a truncated branch
offset?

If a program has PROBE_MEM accesses and the offset between the fixup
routine and the main program exceeds 32MB, it seems the CPU might jump to
a corrupted address after handling the exception. Is it worth validating
the branch offset here as well?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1786099877.git.skb99@linux.ibm.com?part=7

  reply	other threads:[~2026-08-07 12:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1786099877.git.skb99@linux.ibm.com>
2026-08-07 11:42 ` [PATCH v11 1/8] powerpc/bpf: fix alignment of long branch trampoline address Saket Kumar Bhaskar
2026-08-07 12:00   ` sashiko-bot
2026-08-07 11:42 ` [PATCH v11 2/8] powerpc/bpf: Move out dummy_tramp_addr after Long branch stub Saket Kumar Bhaskar
2026-08-07 11:42 ` [PATCH v11 3/8] selftests/bpf: Fixing powerpc JIT disassembly failure Saket Kumar Bhaskar
2026-08-07 12:59   ` bot+bpf-ci
2026-08-07 11:42 ` [PATCH v11 4/8] selftests/bpf: Enable verifier selftest for powerpc64 Saket Kumar Bhaskar
2026-08-07 11:42 ` [PATCH v11 5/8] powerpc64/bpf: fix compare instruction emitted for tailcall Saket Kumar Bhaskar
2026-08-07 11:42 ` [PATCH v11 6/8] selftests/bpf: Add tailcall verifier selftest for powerpc64 Saket Kumar Bhaskar
2026-08-07 12:32   ` sashiko-bot
2026-08-07 11:42 ` [PATCH v11 7/8] powerpc/bpf: fix buffer overflow in JIT for large BPF programs Saket Kumar Bhaskar
2026-08-07 12:41   ` sashiko-bot [this message]
2026-08-07 11:42 ` [PATCH v11 8/8] powerpc64/bpf: fix percpu private stack leak on JIT failure Saket Kumar Bhaskar
2026-08-07 13:04   ` 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=20260807124159.4E3461F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=skb99@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox