From: Xu Kuohai <xukuohai@huaweicloud.com>
To: bot+bpf-ci@kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
martin.lau@linux.dev, eddyz87@gmail.com, yonghong.song@linux.dev,
puranjay@kernel.org, a.s.protopopov@gmail.com,
alexis.lothore@bootlin.com, list+bpf@vahedi.org,
linux@armlinux.org.uk, yangtiezhu@loongson.cn,
hengqi.chen@gmail.com, johan.almbladh@anyfinetworks.com,
paulburton@kernel.org, hbathini@linux.ibm.com,
chleroy@kernel.org, naveen@kernel.org, luke.r.nels@gmail.com,
xi.wang@gmail.com, bjorn@kernel.org, pulehui@huawei.com,
iii@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com,
davem@davemloft.net, udknight@gmail.com, martin.lau@kernel.org,
clm@meta.com, ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v10 1/5] bpf: Move constants blinding out of arch-specific JITs
Date: Wed, 25 Mar 2026 15:47:18 +0800 [thread overview]
Message-ID: <5b24cd1d-a8cf-4c9c-a0c8-c79c10ea80e4@huaweicloud.com> (raw)
In-Reply-To: <edfa617891aa2e2980ecfb8037a7a4ed069e518bbce1777e331c737024feb1da@mail.kernel.org>
On 3/24/2026 8:46 PM, bot+bpf-ci@kernel.org wrote:
>> diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
>> index 67eb12b637a5..8f52f4b6c3af 100644
>> --- a/kernel/bpf/core.c
>> +++ b/kernel/bpf/core.c
>
> [ ... ]
>
>> @@ -1507,13 +1507,16 @@ static void adjust_insn_arrays(struct bpf_prog *prog, u32 off, u32 len)
>> #endif
>> }
>>
>> -struct bpf_prog *bpf_jit_blind_constants(struct bpf_prog *prog)
>> +struct bpf_prog *bpf_jit_blind_constants(struct bpf_verifier_env *env, struct bpf_prog *prog)
>> {
>
> [ ... ]
>
>> - tmp = bpf_patch_insn_single(clone, i, insn_buff, rewritten);
>> - if (IS_ERR(tmp)) {
>> + if (env)
>> + tmp = bpf_patch_insn_data(env, subprog_start + i, insn_buff, rewritten);
>> + else
>> + tmp = bpf_patch_insn_single(clone, i, insn_buff, rewritten);
>
> When env is non-NULL, bpf_patch_insn_data() adjusts env->insn_aux_data
> via adjust_insn_aux_data() and env->subprog_info via
> adjust_subprog_starts(). This shifts subprogram start positions to
> account for the expanded instructions.
>
Right, but only the subsequent subprogs are shifted, the current subprog
is not. Since we are patching the main prog when env is non-NULL, and
subprog_start is always 0 for a main prog, subprog_start is not needed
here and can be removed.
>> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
>> index cd008b146ee5..1b2b99f2d859 100644
>> --- a/kernel/bpf/verifier.c
>> +++ b/kernel/bpf/verifier.c
>
[ ... ]
>> }
>> bpf_prog_jit_attempt_done(prog);
>> return err;
>
> When blinded is true, the rollback restores env->prog to orig_prog, but
> env->subprog_info still holds the shifted start positions from blinding
> (adjusted by adjust_subprog_starts() in bpf_patch_insn_data()). The
> commit message states "env->insn_aux_data and env->subprog_info are no
> longer used after JIT failure." However, on configurations without
> CONFIG_BPF_JIT_ALWAYS_ON, fixup_call_args() falls through to the
> interpreter fixup loop after jit_subprogs() fails:
>
> fixup_call_args() {
> err = jit_subprogs(env); /* fails, e.g. -ENOTSUPP */
> ...
> for (i = 0; i < prog->len; ...) {
> ...
> depth = get_callee_stack_depth(env, insn, i);
> }
> }
>
> get_callee_stack_depth() computes a target address from orig_prog's
> original instruction offsets and calls find_subprog(env, start). Since
> env->subprog_info start positions were shifted by blinding but the
> instruction addresses are from the unblinded orig_prog, find_subprog()
> fails to find a matching entry and returns -ENOENT, triggering a
> spurious "verifier bug" warning and rejecting the program.
>
> Could env->subprog_info be restored alongside the prog rollback, or
> could jit_subprogs() return -EFAULT when blinding was active to skip
> the interpreter fallback path?
>
We can save and restore env->subprog_info. Since only the subprog start
values in the subprog_info array are adjusted by the patching function,
I will just back up the original values and restore them on failure,
without duplicating the full subprog_info array.
>
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
>
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/23488858455
next prev parent reply other threads:[~2026-03-25 7:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 12:20 [PATCH bpf-next v10 0/5] emit ENDBR/BTI instructions for indirect jump targets Xu Kuohai
2026-03-24 12:20 ` [PATCH bpf-next v10 1/5] bpf: Move constants blinding out of arch-specific JITs Xu Kuohai
2026-03-24 12:46 ` bot+bpf-ci
2026-03-25 7:47 ` Xu Kuohai [this message]
2026-03-25 15:12 ` Alexei Starovoitov
2026-03-24 12:20 ` [PATCH bpf-next v10 2/5] bpf: Pass bpf_verifier_env to JIT Xu Kuohai
2026-03-24 12:20 ` [PATCH bpf-next v10 3/5] bpf: Add helper to detect indirect jump targets Xu Kuohai
2026-03-24 12:20 ` [PATCH bpf-next v10 4/5] bpf, x86: Emit ENDBR for " Xu Kuohai
2026-03-25 10:13 ` Leon Hwang
2026-03-24 12:20 ` [PATCH bpf-next v10 5/5] bpf, arm64: Emit BTI for indirect jump target Xu Kuohai
2026-03-25 10:14 ` Leon Hwang
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=5b24cd1d-a8cf-4c9c-a0c8-c79c10ea80e4@huaweicloud.com \
--to=xukuohai@huaweicloud.com \
--cc=a.s.protopopov@gmail.com \
--cc=alexis.lothore@bootlin.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bot+bpf-ci@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chleroy@kernel.org \
--cc=clm@meta.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=gor@linux.ibm.com \
--cc=hbathini@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hengqi.chen@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=iii@linux.ibm.com \
--cc=johan.almbladh@anyfinetworks.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=list+bpf@vahedi.org \
--cc=luke.r.nels@gmail.com \
--cc=martin.lau@kernel.org \
--cc=martin.lau@linux.dev \
--cc=naveen@kernel.org \
--cc=paulburton@kernel.org \
--cc=pulehui@huawei.com \
--cc=puranjay@kernel.org \
--cc=udknight@gmail.com \
--cc=xi.wang@gmail.com \
--cc=yangtiezhu@loongson.cn \
--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
all inboxes | Powered by JetHome®