]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Add enum64 sanitization
authorYonghong Song <yhs@fb.com>
Tue, 7 Jun 2022 06:26:36 +0000 (23:26 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 7 Jun 2022 17:20:43 +0000 (10:20 -0700)
commita7478f5816b614185e2aa2434b5cbf2464fd6844
tree99f5cdd3421a3d03753bdb927e66317f7b6f6943
parent5cfa9385526b1f0b7fbaaf755cdb8e0c5b2c3831
libbpf: Add enum64 sanitization

When old kernel does not support enum64 but user space btf
contains non-zero enum kflag or enum64, libbpf needs to
do proper sanitization so modified btf can be accepted
by the kernel.

Sanitization for enum kflag can be achieved by clearing
the kflag bit. For enum64, the type is replaced with an
union of integer member types and the integer member size
must be smaller than enum64 size. If such an integer
type cannot be found, a new type is created and used
for union members.

Acked-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/r/20220607062636.3721375-1-yhs@fb.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/btf.h
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf_internal.h