Re: [PATCH 1/3] bpf: verifier: Accept dynptr mem as mem in helpers

From: Andrii Nakryiko
Date: Wed May 03 2023 - 14:39:54 EST


On Mon, May 1, 2023 at 6:12 PM Daniel Rosenberg <drosen@xxxxxxxxxx> wrote:
>
> On Thu, Apr 6, 2023 at 3:13 PM Alexei Starovoitov
> <alexei.starovoitov@xxxxxxxxx> wrote:
> >
> > +1
> > All of the DYNPTR_TYPE_FLAG_MASK flags cannot appear in type == reg->type
> > here.
> > They are either dynamic flags inside bpf_dynptr_kern->size
> > or in arg_type.
> > Like in bpf_dynptr_from_mem_proto.
>
> Looking at this a bit more, I believe this is to enforce packet
> restrictions for DYNPTR_TYPE_SKB and DYNPTR_TYPE_XDP. When a helper
> function alters a packet, dynptr slices of it are invalidated. If I
> remove that annotation entirely, then the invalid_data_slice family of
> tests fail. bpf_dynptr_from_mem_proto is fine since that's just local
> dynptrs, which don't have any extra limitations.


Ah, ok, thanks for investigating!