Re: [PATCH bpf-next v1 3/8] bpf: Introduce load-acquire and store-release instructions
From: Peilin Ye
Date: Wed Jan 29 2025 - 17:18:10 EST
On Tue, Jan 28, 2025 at 05:30:19PM -0800, Eduard Zingerman wrote:
> On Sat, 2025-01-25 at 02:18 +0000, Peilin Ye wrote:
> > +static int check_atomic_store(struct bpf_verifier_env *env, int insn_idx,
> > + struct bpf_insn *insn)
> > +{
> > + int err;
> > +
> > + err = check_reg_arg(env, insn->src_reg, SRC_OP);
> > + if (err)
> > + return err;
> > +
> > + err = check_reg_arg(env, insn->dst_reg, SRC_OP);
> > + if (err)
> > + return err;
> > +
> > + if (is_pointer_value(env, insn->src_reg)) {
> > + verbose(env, "R%d leaks addr into mem\n", insn->src_reg);
> > + return -EACCES;
> > + }
>
> Nit: this check is done by check_mem_access(), albeit only for
> PTR_TO_MEM, I think it's better to be consistent with
> what happens for regular stores and avoid this check here.
Got it. Unprivileged programs will be able to store-release pointers to
the stack, then. I'll update selftests accordingly.
Thanks,
Peilin Ye