Skip to content

Commit e697d8d

Browse files
olsajiriAlexei Starovoitov
authored andcommitted
selftests/bpf: Add kprobe_multi check to module attach test
Adding test that makes sure the kernel module won't be removed if there's kprobe multi link defined on top of it. Acked-by: Song Liu <song@kernel.org> Signed-off-by: Jiri Olsa <jolsa@kernel.org> Link: https://lore.kernel.org/r/20221025134148.3300700-8-jolsa@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent fee356e commit e697d8d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

tools/testing/selftests/bpf/prog_tests/module_attach.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ void test_module_attach(void)
103103
ASSERT_ERR(delete_module("bpf_testmod", 0), "delete_module");
104104
bpf_link__destroy(link);
105105

106+
link = bpf_program__attach(skel->progs.kprobe_multi);
107+
if (!ASSERT_OK_PTR(link, "attach_kprobe_multi"))
108+
goto cleanup;
109+
110+
ASSERT_ERR(delete_module("bpf_testmod", 0), "delete_module");
111+
bpf_link__destroy(link);
112+
106113
cleanup:
107114
test_module_attach__destroy(skel);
108115
}

tools/testing/selftests/bpf/progs/test_module_attach.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,10 @@ int BPF_PROG(handle_fmod_ret,
110110
return 0; /* don't override the exit code */
111111
}
112112

113+
SEC("kprobe.multi/bpf_testmod_test_read")
114+
int BPF_PROG(kprobe_multi)
115+
{
116+
return 0;
117+
}
118+
113119
char _license[] SEC("license") = "GPL";

0 commit comments

Comments
 (0)