Re: [PATCH bpf-next v2] bpf: Propagate memory bounds to registers in atomics w/ BPF_FETCH

2021-02-02 Thread Brendan Jackman
On Tue, 2 Feb 2021 at 00:27, Alexei Starovoitov wrote: > > On Mon, Feb 1, 2021 at 7:00 AM Brendan Jackman wrote: > > + > > +SEC("fentry/bpf_fentry_test1") > > +int BPF_PROG(sub, int x) > > +{ > > + int a = 0; > > + int b = __sync_fetch_and_add(, 1); > > It probably needs

Re: [PATCH bpf-next v2] bpf: Propagate memory bounds to registers in atomics w/ BPF_FETCH

2021-02-01 Thread Alexei Starovoitov
On Mon, Feb 1, 2021 at 7:00 AM Brendan Jackman wrote: > + > +SEC("fentry/bpf_fentry_test1") > +int BPF_PROG(sub, int x) > +{ > + int a = 0; > + int b = __sync_fetch_and_add(, 1); It probably needs ENABLE_ATOMICS_TESTS ? Otherwise clang without -mcpu=v3 will complain: "fatal error:

[PATCH bpf-next v2] bpf: Propagate memory bounds to registers in atomics w/ BPF_FETCH

2021-02-01 Thread Brendan Jackman
When BPF_FETCH is set, atomic instructions load a value from memory into a register. The current verifier code first checks via check_mem_access whether we can access the memory, and then checks via check_reg_arg whether we can write into the register. For loads, check_reg_arg has the side-effect