From: sashiko-bot@kernel.org
To: "Yonghong Song" <yonghong.song@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v6 03/10] bpf: Wire up JIT support for 16-byte kfunc returns
Date: Mon, 17 Aug 2026 04:37:53 +0000 [thread overview]
Message-ID: <20260817043753.89D311F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260817042156.2287455-1-yonghong.song@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The BPF verifier fails to initialize BPF_REG_2 for 16-byte scalar kfunc returns, breaking the feature.
--
--- Patch [3]: [PATCH bpf-next v6 03/10] bpf: Wire up JIT support for 16-byte kfunc returns ---
commit 70077e00d2d0c46ef0daa85eb2612ed7fbf545ef
Author: Yonghong Song <yonghong.song@linux.dev>
bpf: Wire up JIT support for 16-byte kfunc returns
This commit wires up JIT support for 16-byte kfunc returns in BPF, such as
large structs or 128-bit integers. It adds support to the x86-64, arm64, and
riscv64 JITs to return the second half of the value in BPF_REG_2, and adds
verifier checks to reject larger returns on unsupported architectures.
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index f1f1268d29c66..54aca6c305061 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
[ ... ]
> @@ -2920,6 +2920,18 @@ int bpf_add_kfunc_call(struct bpf_verifier_env *env, u32 func_id, u16 offset)
> err = btf_distill_func_proto(&env->log, kfunc.btf, kfunc.proto, kfunc.name, &func_model);
> if (err)
> return err;
> + if (func_model.ret_size > 8) {
> + if (kfunc.flags && (*kfunc.flags & KF_FASTCALL)) {
> + verbose(env, "kfunc %s with >8-byte return is not supported with KF_FASTCALL\n",
> + kfunc.name);
> + return -EOPNOTSUPP;
> + }
> + if (!bpf_jit_supports_kfunc_ret_reg_pair()) {
> + verbose(env, "kfunc %s with >8-byte return is not supported by JIT\n",
> + kfunc.name);
> + return -EOPNOTSUPP;
> + }
> + }
[Severity: Medium]
While this patch adds JIT support and basic verifier checks for >8-byte
returns, does the verifier correctly initialize BPF_REG_2 for 16-byte scalar
returns?
Looking at check_kfunc_call() in kernel/bpf/verifier.c, it seems only
BPF_REG_0 is marked as initialized for scalar returns:
if (btf_type_is_scalar(t)) {
mark_reg_unknown(env, regs, BPF_REG_0);
if (meta.btf == btf_vmlinux &&
(meta.func_id == special_kfunc_list[KF_bpf_res_spin_lock] || ...
Since BPF caller-saved registers (including BPF_REG_2) are marked as NOT_INIT
earlier in check_kfunc_call(), a BPF program attempting to access the upper
64 bits of a 16-byte scalar (like an __int128) in BPF_REG_2 would be rejected
with a verifier read error.
Should check_kfunc_call() also initialize BPF_REG_2 when the return size is
greater than 8 bytes?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260817042141.2286086-1-yonghong.song@linux.dev?part=3
next prev parent reply other threads:[~2026-08-17 4:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 4:21 [PATCH bpf-next v6 00/10] bpf: Support aggregate return values up to 16 bytes Yonghong Song
2026-08-17 4:21 ` [PATCH bpf-next v6 01/10] bpf: Factor check_global_ret_scalar_reg() out of the global return check Yonghong Song
2026-08-17 4:21 ` [PATCH bpf-next v6 02/10] bpf: Add helpers to describe the R0:R2 return register pair Yonghong Song
2026-08-17 5:17 ` bot+bpf-ci
2026-08-17 4:21 ` [PATCH bpf-next v6 03/10] bpf: Wire up JIT support for 16-byte kfunc returns Yonghong Song
2026-08-17 4:37 ` sashiko-bot [this message]
2026-08-17 4:22 ` [PATCH bpf-next v6 04/10] bpf: Handle R2 as a return register in precision backtracking Yonghong Song
2026-08-17 5:17 ` bot+bpf-ci
2026-08-17 4:22 ` [PATCH bpf-next v6 05/10] bpf: Account R2 of register-pair returns in live register analysis Yonghong Song
2026-08-17 4:43 ` sashiko-bot
2026-08-17 4:22 ` [PATCH bpf-next v6 06/10] bpf: Add verifier support for 16-byte returns in R0:R2 Yonghong Song
2026-08-17 4:42 ` sashiko-bot
2026-08-17 5:17 ` bot+bpf-ci
2026-08-17 4:22 ` [PATCH bpf-next v6 07/10] bpf: Enable aggregate return types up to 16 bytes Yonghong Song
2026-08-17 4:42 ` sashiko-bot
2026-08-17 4:22 ` [PATCH bpf-next v6 08/10] selftests/bpf: Add C tests for 16-byte returns in R0:R2 Yonghong Song
2026-08-17 4:45 ` sashiko-bot
2026-08-17 4:22 ` [PATCH bpf-next v6 09/10] selftests/bpf: Add inline-asm and subprog tests for R0:R2 returns Yonghong Song
2026-08-17 4:42 ` sashiko-bot
2026-08-17 5:17 ` bot+bpf-ci
2026-08-17 4:22 ` [PATCH bpf-next v6 10/10] Documentation/bpf: Document up to 16-byte kfunc return values in R0:R2 Yonghong Song
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=20260817043753.89D311F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yonghong.song@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