]>
git.ipfire.org Git - thirdparty/util-linux.git/commit
lsfd: use memset explicitly to fill bpf_attr with zero
The original code used initialize-lists for initializing
variables (attr) type of union bpf_attr.
However, the folloing syscalls failed with EINVAL:
syscall(SYS_bpf, BPF_PROG_GET_FD_BY_ID, &attr, sizeof(attr));
syscall(SYS_bpf, BPF_MAP_GET_FD_BY_ID, &attr, sizeof(attr));
CHECK_ATTR macro of Linux might cause EINVAL:
/* helper macro to check that unused fields 'union bpf_attr' are zero */
#define CHECK_ATTR(CMD) \
memchr_inv((void *) &attr->CMD##_LAST_FIELD + \
sizeof(attr->CMD##_LAST_FIELD), 0, \
sizeof(*attr) - \
offsetof(union bpf_attr, CMD##_LAST_FIELD) - \
sizeof(attr->CMD##_LAST_FIELD)) != NULL
I doubt initialize-lists worked well.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>