tag_of_vmlinux attaches to the bpf_dummy_reg() of bpf_testmod. It shares the FUNC of vmlinux with a bpf_dummy_reg() which has a tag, and the verifier must not take that tag. But the one of vmlinux takes a struct bpf_link, and the build is going to stop tagging such functions. The test would then pass without testing anything. Use do_epoll_create() instead, and load a program on the one of vmlinux: if it loses its tag, that test fails. It needs CONFIG_EPOLL, add it to the config of the selftests. (It is on by default, but make it explicit.) Signed-off-by: Anton Protopopov --- tools/testing/selftests/bpf/config | 1 + .../selftests/bpf/progs/fmodret_retval.c | 17 ++++++++++++----- .../bpf/test_kmods/bpf_testmod_retval.c | 6 ++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/bpf/config b/tools/testing/selftests/bpf/config index 30b744844ef5..ce0db4be4d26 100644 --- a/tools/testing/selftests/bpf/config +++ b/tools/testing/selftests/bpf/config @@ -30,6 +30,7 @@ CONFIG_DMABUF_HEAPS=y CONFIG_DMABUF_HEAPS_SYSTEM=y CONFIG_DUMMY=y CONFIG_DYNAMIC_FTRACE=y +CONFIG_EPOLL=y CONFIG_FPROBE=y CONFIG_FTRACE_SYSCALLS=y CONFIG_FUNCTION_ERROR_INJECTION=y diff --git a/tools/testing/selftests/bpf/progs/fmodret_retval.c b/tools/testing/selftests/bpf/progs/fmodret_retval.c index 112f1575ce1f..ae2332bff2f0 100644 --- a/tools/testing/selftests/bpf/progs/fmodret_retval.c +++ b/tools/testing/selftests/bpf/progs/fmodret_retval.c @@ -176,13 +176,20 @@ int BPF_PROG(not_a_target, int value, int ret) return 0; } +SEC("fmod_ret/do_epoll_create") +__success +int BPF_PROG(tag_in_vmlinux, int flags, int ret) +{ + return 0; +} + /* - * vmlinux has a bpf_dummy_reg() of the same type, so the two share the FUNC of - * vmlinux. That one returns an error and has a tag. This one returns only 0. + * The do_epoll_create() of bpf_testmod has the type of the one of vmlinux, so + * the two share the FUNC of vmlinux. This one returns only 0. */ -SEC("fmod_ret/bpf_testmod:bpf_dummy_reg") -__failure __msg("bpf_dummy_reg() is not modifiable") -int BPF_PROG(tag_of_vmlinux, void *kdata, struct bpf_link *link, int ret) +SEC("fmod_ret/bpf_testmod:do_epoll_create") +__failure __msg("do_epoll_create() is not modifiable") +int BPF_PROG(tag_of_vmlinux, int flags, int ret) { return 0; } diff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod_retval.c b/tools/testing/selftests/bpf/test_kmods/bpf_testmod_retval.c index 85722e48d34c..ba48f0f393f3 100644 --- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod_retval.c +++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod_retval.c @@ -159,3 +159,9 @@ static __used noinline __init int bpf_testmod_retval_init(int value) { return value ? -EINVAL : -ENOMEM; } + +/* vmlinux has a do_epoll_create() of this type, which returns errors */ +static __used noinline int do_epoll_create(int flags) +{ + return 0; +} -- 2.43.0