]> www.infradead.org Git - users/jedix/linux-maple.git/commit
selftests/bpf: Make sure libbpf doesn't enforce the signature of a func pointer.
authorKui-Feng Lee <thinker.li@gmail.com>
Thu, 4 Apr 2024 23:23:42 +0000 (16:23 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 5 Apr 2024 17:33:18 +0000 (10:33 -0700)
commitba0cbe2bb4ab8aa266e48c6399bebf6e1217828a
tree318c36052520f655e96c0b6391e27c75b3be39f1
parent270954791c706b133a03b01e4b2d063dc870f704
selftests/bpf: Make sure libbpf doesn't enforce the signature of a func pointer.

The verifier in the kernel ensures that the struct_ops operators behave
correctly by checking that they access parameters and context
appropriately. The verifier will approve a program as long as it correctly
accesses the context/parameters, regardless of its function signature. In
contrast, libbpf should not verify the signature of function pointers and
functions to enable flexibility in loading various implementations of an
operator even if the signature of the function pointer does not match those
in the implementations or the kernel.

With this flexibility, user space applications can adapt to different
kernel versions by loading a specific implementation of an operator based
on feature detection.

This is a follow-up of the commit c911fc61a7ce ("libbpf: Skip zeroed or
null fields if not found in the kernel type.")

Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240404232342.991414-1-thinker.li@gmail.com
tools/testing/selftests/bpf/prog_tests/test_struct_ops_module.c
tools/testing/selftests/bpf/progs/struct_ops_module.c