On Tue, 23 Aug 2022 12:11:38 -0700 Joanne Koong <joannelkoong@xxxxxxxxx> wrote: > The "ptr->offset > size" check isn't quite correct because size is the > number of usable bytes (more on this below :)) > > > + return NULL; > > + *avail_bytes = size - ptr->offset; > > dynptr->size is already the number of usable bytes; this is noted in > include/linux/bpf.h > > /* the implementation of the opaque uapi struct bpf_dynptr */ > struct bpf_dynptr_kern { > void *data; > /* Size represents the number of usable bytes of dynptr data. Thanks. BTW, despite the comment I was under the impression the 'size' is the *fixed* allocation size associated with 'data' (and not the usable bytes left at data+offset), since (1) havn't encounterd 'size' adjustments in the helpers code, and (2) 'size' arithmetic isn't trivial (due to the flags stored into size's upper bits). Therefore, assumed it is probably the fixed size. Anyway will fix the new 'bpf_dynptr_get_data'. Best, Shmulik