All of lore.kernel.org
 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 2/2] powerpc64/bpf: Fix build break for arch_bpf_timed_may_goto
Date: Wed, 29 Jul 2026 16:18:18 +0000	[thread overview]
Message-ID: <20260729161818.A5AB21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <c57271230ed1c33fffe0704de86d2ee8a557a553.1785339155.git.skb99@linux.ibm.com>

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

Pre-existing issues:
- [Critical] The assembly trampoline `arch_bpf_timed_may_goto` saves BPF registers in the callee's parameter save area, exposing them to silent corruption by the C function `bpf_check_timed_may_goto`.
--

--- Patch [2]: [PATCH 2/2] powerpc64/bpf: Fix build break for arch_bpf_timed_may_goto ---
commit 991cd0fd25b432c448bce574ccb7dc7d8af6d3a2
Author: Saket Kumar Bhaskar <skb99@linux.ibm.com>

powerpc64/bpf: Fix build break for arch_bpf_timed_may_goto

With CONFIG_PPC_KERNEL_PCREL enabled, calling bpf_check_timed_may_goto()
using a bl instruction results in a link-time failure. This commit replaces
the direct 'bl' call with the CFUNC() macro to properly annotate the call,
avoiding the TOC restoration linker error.

> diff --git a/arch/powerpc/net/bpf_timed_may_goto.S b/arch/powerpc/net/bpf_timed_may_goto.S
> index 6fd8b1c9f4ac8..84ecf6fa7f5dc 100644
> --- a/arch/powerpc/net/bpf_timed_may_goto.S
> +++ b/arch/powerpc/net/bpf_timed_may_goto.S
> @@ -36,7 +36,7 @@ SYM_FUNC_START(arch_bpf_timed_may_goto)
>  	 * BPF_REG_FP is r31; BPF_REG_AX is r12 (stack offset in bytes).
>  	 */
>  	add     r3, r31, r12
> -	bl      bpf_check_timed_may_goto
> +	bl      CFUNC(bpf_check_timed_may_goto)

[Severity: Critical]
This is a pre-existing issue, but does this function corrupt the saved BPF
registers by placing them in the callee's parameter save area?

In arch_bpf_timed_may_goto, the stack frame is allocated with 112 bytes, and
the BPF registers are saved from offsets 32(r1) to 72(r1):

    stdu    r1, -112(r1)
    ...
    std     r3, 32(r1)
    ...
    std     r8, 72(r1)

According to the PowerPC64 ELF ABI, offsets 32(r1) to 95(r1) in the caller's
frame are the parameter save area reserved for the callee.

When we call the C function bpf_check_timed_may_goto(), the compiler is
allowed to use this parameter save area (e.g., to spill the 'p' argument
when it calls ktime_get_mono_fast_ns()). If it does, it will silently
overwrite the saved BPF registers.

Upon return from bpf_check_timed_may_goto(), arch_bpf_timed_may_goto
restores these registers, which could now hold corrupted values:

    ld      r3, 32(r1)
    ...
    ld      r8, 72(r1)

Could this lead to silent data corruption or panics during BPF program
execution?

>  
>  	/* Put return value back into AX */
>  	mr      r12, r3

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

  reply	other threads:[~2026-07-29 16:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29 16:03 [PATCH 0/2] powerpc64/bpf: Fix PCREL build breaks Saket Kumar Bhaskar
2026-07-29 16:03 ` [PATCH 1/2] powerpc64/bpf: Fix build break in bpf_jit_emit_func_call_rel() Saket Kumar Bhaskar
2026-07-29 16:45   ` Christophe Leroy (CS GROUP)
2026-07-29 16:03 ` [PATCH 2/2] powerpc64/bpf: Fix build break for arch_bpf_timed_may_goto Saket Kumar Bhaskar
2026-07-29 16:18   ` sashiko-bot [this message]
2026-07-29 16:47   ` Christophe Leroy (CS GROUP)

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=20260729161818.A5AB21F000E9@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 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.