[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQLgPBcRAqKfCXQwZae2jKDfp=xSFZCgzHgg-jcBTYp-yw@mail.gmail.com>
Date: Wed, 21 May 2025 13:04:47 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Eduard Zingerman <eddyz87@...il.com>, Peilin Ye <yepeilin@...gle.com>
Cc: Puranjay Mohan <puranjay@...nel.org>, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, John Fastabend <john.fastabend@...il.com>,
Andrii Nakryiko <andrii@...nel.org>, Martin KaFai Lau <martin.lau@...ux.dev>, Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>, KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...gle.com>, Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
bpf <bpf@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH bpf] bpf: verifier: support BPF_LOAD_ACQ in insn_def_regno()
On Wed, May 21, 2025 at 12:13 PM Eduard Zingerman <eddyz87@...il.com> wrote:
>
>
> On 2025-05-21 11:39, Puranjay Mohan wrote:
> [...]
> > @@ -3643,6 +3643,9 @@ static bool is_reg64(struct bpf_verifier_env *env, struct bpf_insn *insn,
> > /* Return the regno defined by the insn, or -1. */
> > static int insn_def_regno(const struct bpf_insn *insn)
> > {
> > + if (is_atomic_load_insn(insn))
> > + return insn->dst_reg;
> > +
> > switch (BPF_CLASS(insn->code)) {
> > case BPF_JMP:
> > case BPF_JMP32:
>
> I'm confused, is_atomic_load_insn() is defined as:
>
> return BPF_CLASS(insn->code) == BPF_STX &&
> BPF_MODE(insn->code) == BPF_ATOMIC &&
> insn->imm == BPF_LOAD_ACQ;
>
> And insn_def_regno() has the following case:
>
> case BPF_STX:
> if (BPF_MODE(insn->code) == BPF_ATOMIC ||
> BPF_MODE(insn->code) == BPF_PROBE_ATOMIC) {
> if (insn->imm == BPF_CMPXCHG)
> return BPF_REG_0;
> else if (insn->imm == BPF_LOAD_ACQ)
> return insn->dst_reg;
> else if (insn->imm & BPF_FETCH)
> return insn->src_reg;
> }
> return -1;
>
> Why is it not triggering?
>
> Also, can this be tested with a BPF_F_TEST_RND_HI32 flag?
> E.g. see verifier_scalar_ids.c:linked_regs_and_subreg_def() test case.
I suspect it was already fixed by commit
fce7bd8e385a ("bpf/verifier: Handle BPF_LOAD_ACQ instructions in
insn_def_regno()")
Powered by blists - more mailing lists