mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bot+bpf-ci@kernel.org
To: xukuohai@huaweicloud.com,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,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,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,clm@meta.com,ihor.solodrai@linux.dev
Subject: Re: [bpf-next v6 1/5] bpf: Move constants blinding from JIT to verifier
Date: Fri,  6 Mar 2026 10:38:05 +0000 (UTC)	[thread overview]
Message-ID: <48167f373db21bc7817e4e69b8be017c5c0a26bc54b8dd30206dd1b0ebc3a944@mail.kernel.org> (raw)
In-Reply-To: <20260306102329.2056216-2-xukuohai@huaweicloud.com>

[-- Attachment #1: Type: text/plain, Size: 2374 bytes --]

> diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> index adf84962d579..c5ed9d84c3ae 100644
> --- a/arch/arm64/net/bpf_jit_comp.c
> +++ b/arch/arm64/net/bpf_jit_comp.c

[ ... ]

> @@ -2201,7 +2170,6 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
>  		if (WARN_ON(bpf_jit_binary_pack_finalize(ro_header, header))) {
>  			/* ro_header has been freed */
>  			ro_header = NULL;
> -			prog = orig_prog;
>  			goto out_off;
>  		}

With the orig_prog fallback removed, if bpf_jit_binary_pack_finalize()
fails on the extra pass, prog->bpf_func and prog->jited still hold
the values set during the first pass. At that point ro_header has been
freed, so bpf_func points to freed memory.

In jit_subprogs() the second loop checks:

    old_bpf_func = func[i]->bpf_func;
    tmp = bpf_int_jit_compile(func[i]);
    if (tmp != func[i] || func[i]->bpf_func != old_bpf_func) {

Since bpf_func is unchanged, this does not detect the failure. The
program continues with jited=1 and a stale bpf_func.

The powerpc and riscv JITs handle this correctly in the same commit:

arch/riscv/net/bpf_jit_core.c:bpf_int_jit_compile():

    if (WARN_ON(bpf_jit_binary_pack_finalize(...))) {
            jit_data->ro_header = NULL;
            prog->bpf_func = NULL;
            prog->jited = 0;
            prog->jited_len = 0;
            goto out_offset;
    }

Should the arm64 path also clear bpf_func, jited, and jited_len here
to match?

> diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c
> index 3bd89f55960d..3a5cc3e88424 100644
> --- a/arch/loongarch/net/bpf_jit.c
> +++ b/arch/loongarch/net/bpf_jit.c

[ ... ]

> @@ -2041,7 +2014,6 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
>  		if (WARN_ON(bpf_jit_binary_pack_finalize(ro_header, header))) {
>  			/* ro_header has been freed */
>  			ro_header = NULL;
> -			prog = orig_prog;
>  			goto out_free;
>  		}

Same issue as arm64 above. The loongarch JIT also sets prog->jited and
prog->bpf_func before finalize, and the failure path does not clear
them. Would it make sense to add the same clearing here as well?


---
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/22758822985

  reply	other threads:[~2026-03-06 10:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-06 10:23 [bpf-next v6 0/5] emit ENDBR/BTI instructions for indirect jump targets Xu Kuohai
2026-03-06 10:23 ` [bpf-next v6 1/5] bpf: Move constants blinding from JIT to verifier Xu Kuohai
2026-03-06 10:38   ` bot+bpf-ci [this message]
2026-03-06 18:30   ` Alexei Starovoitov
2026-03-07  3:10     ` Xu Kuohai
2026-03-06 10:23 ` [bpf-next v6 2/5] bpf: Pass bpf_verifier_env to jit Xu Kuohai
2026-03-07  6:40   ` Yeoreum Yun
2026-03-07  6:57     ` Xu Kuohai
2026-03-07  7:22       ` Yeoreum Yun
2026-03-07  7:35         ` Xu Kuohai
2026-03-07  8:00           ` Yeoreum Yun
2026-03-06 10:23 ` [bpf-next v6 3/5] bpf: Add helper to detect indirect jump targets Xu Kuohai
2026-03-06 10:23 ` [bpf-next v6 4/5] bpf, x86: Emit ENDBR for " Xu Kuohai
2026-03-07  1:36   ` Eduard Zingerman
2026-03-07  3:15     ` Xu Kuohai
2026-03-07  3:31       ` Alexei Starovoitov
2026-03-07  3:56         ` Xu Kuohai
2026-03-06 10:23 ` [bpf-next v6 5/5] bpf, arm64: Emit BTI for indirect jump target Xu Kuohai

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=48167f373db21bc7817e4e69b8be017c5c0a26bc54b8dd30206dd1b0ebc3a944@mail.kernel.org \
    --to=bot+bpf-ci@kernel.org \
    --cc=a.s.protopopov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bjorn@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=xukuohai@huaweicloud.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®