BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Anton Protopopov" <a.s.protopopov@gmail.com>, bpf@vger.kernel.org
Subject: Re: [PATCH v3 bpf-next 14/18] bpf: Require the JIT for fmod_ret programs on found 64-bit targets
Date: Tue, 10 Nov 2026 17:38:23 +0000	[thread overview]
Message-ID: <sashiko-outbox-207493@kernel.org> (raw)
In-Reply-To: <20261110164046.454431-15-a.s.protopopov@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] bpf: missing jit_required in fmodret_retval_init() for 32-bit
  int on ppc64
--

commit be8ba9e6d31af4b7ee8b1ec3bc7241dc8e6ff517
Author: Anton Protopopov <a.s.protopopov@gmail.com>

bpf: Require the JIT for fmod_ret programs on found 64-bit targets

This commit sets jit_required for fmod_ret programs attached to found
targets with 8-byte return types so the BPF interpreter does not truncate
64-bit return values to 32 bits.

> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index b12b57c7403e4..920ff39aac429 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -23883,6 +23883,9 @@ static int fmodret_retval_init(struct bpf_verifier_env *env, u32 btf_id,
>  
>  	aux->fmodret_retvals = retvals;
>  	aux->fmodret_retval_cnt = cnt;
> +	/* The interpreter returns only 32 bits */
> +	if (size == 8)
> +		env->prog->jit_required = 1;

[Severity: Medium]
Does fmodret_retval_init() also need to set jit_required when size == 4?

On 64-bit PowerPC (which supports BPF trampolines without selecting
ARCH_WANT_BPF_JIT_ALWAYS_ON), the ELF ABI requires a callee returning a
32-bit signed int to sign-extend r3 to 64 bits, and callers inspect all 64
bits of r3.  DEFINE_BPF_PROG_RUN() defines the interpreter entry points as
returning unsigned int, which zero-extends r3 to 64 bits.

In arch/powerpc/net/bpf_jit_comp.c, invoke_bpf_prog() and
__arch_prepare_bpf_trampoline() save and restore all 64 bits of r3 without
sign-extending 32-bit return values, so when the interpreter runs an
fmod_ret program on a target returning int, a negative error return value
is zero-extended to a positive 64-bit value in r3 while skipping the
target function.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261110164046.454431-1-a.s.protopopov@gmail.com?part=14

  reply	other threads:[~2026-11-10 17:38 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 16:40 [PATCH v3 bpf-next 00/18] Auto-detect BPF fmodret targets Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 01/18] bpf: Add BTF ID sets for fmod_ret targets Anton Protopopov
2026-11-11  8:01   ` bot+bpf-ci
2026-11-11 10:32     ` Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 02/18] bpf: Add a btf_id_set8_entry helper Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 03/18] bpf: Build fmod_ret target sets from BTF decl tags Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 04/18] selftests/bpf: Declare bpf_fentry_test1 in tracing tests Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 05/18] bpf: Declare fmod_ret targets with BTF_FMODRET sets Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 06/18] selftests/bpf: Test fmod_ret BTF decl tags and attach permission Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 07/18] scripts: Add LLVM plugin infrastructure Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 08/18] bpf: Add the bpf_scan_ir LLVM plugin Anton Protopopov
2026-11-11  8:21   ` bot+bpf-ci
2026-11-11 11:13     ` Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 09/18] bpf: Find fmod_ret candidates in bpf_scan_ir Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 10/18] bpf: Allow writes to private stack objects " Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 11/18] bpf: Follow PHIs " Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 12/18] bpf: Follow integer casts " Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 13/18] bpf: Check the return values of fmod_ret programs on found targets Anton Protopopov
2026-11-11  8:21   ` bot+bpf-ci
2026-11-11 11:17     ` Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 14/18] bpf: Require the JIT for fmod_ret programs on found 64-bit targets Anton Protopopov
2026-11-10 17:38   ` sashiko-bot [this message]
2026-11-11 10:58     ` Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 15/18] resolve_btfids: Tag fmod_ret candidates as targets Anton Protopopov
2026-11-11  8:21   ` bot+bpf-ci
2026-11-11 11:25     ` Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 16/18] selftests/bpf: Test fmod_ret candidates found by bpf_scan_ir Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 17/18] selftests/bpf: Enable bpf_scan_ir in the config Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 18/18] bpftool: List and show fmod_ret targets Anton Protopopov

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=sashiko-outbox-207493@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=a.s.protopopov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox