On 28/11/2022 16:05, Zachary Leaf wrote:
/* copy attributes from user space, may be less than sizeof(bpf_attr) */
- memset(&attr, 0, sizeof(attr));
- if (copy_from_bpfptr_with_ptr(&attr, uattr, size) != 0)
- memset(vattr, 0, attrsz);
- if (copy_from_bpfptr_with_ptr(vattr, uattr, size) != 0)
Note that _with_ptr is only appropriate for native, in compat there is no actual user pointer in the struct.
Ack. I assume you mean in compat there *is* user pointers, it just doesn't have a capability so makes no sense to go through the capability preserving _with_ptr variant.
This is a bit subtle indeed. There are technically no user pointers in compat structs, in the sense of no *native* user pointers. There can however be *compat* user pointers, i.e. compat_uptr_t (or compat_caddr_t). The _with_ptr variants are only concerned with native user pointers, which is alright for supporting compat64 in addition to compat32; in both cases compat user pointers remain integers.
Kevin