diff options
author | Yonghong Song <yhs@fb.com> | 2021-09-28 20:30:00 -0700 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2021-09-28 23:17:22 -0700 |
commit | 38261f369fb905552ebdd3feb9699c0788fd3371 (patch) | |
tree | cde70ab5309104e14ee36baaabf5fabf3426ae01 /tools/testing/selftests/bpf/prog_tests/probe_user.c | |
parent | 72e1781a5de9e3ee804e24f7ce9a7dd85596fc51 (diff) | |
download | linux-38261f369fb905552ebdd3feb9699c0788fd3371.tar.gz linux-38261f369fb905552ebdd3feb9699c0788fd3371.tar.bz2 linux-38261f369fb905552ebdd3feb9699c0788fd3371.zip |
selftests/bpf: Fix probe_user test failure with clang build kernel
clang build kernel failed the selftest probe_user.
$ ./test_progs -t probe_user
$ ...
$ test_probe_user:PASS:get_kprobe_res 0 nsec
$ test_probe_user:FAIL:check_kprobe_res wrong kprobe res from probe read: 0.0.0.0:0
$ #94 probe_user:FAIL
The test attached to kernel function __sys_connect(). In net/socket.c, we have
int __sys_connect(int fd, struct sockaddr __user *uservaddr, int addrlen)
{
......
}
...
SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
int, addrlen)
{
return __sys_connect(fd, uservaddr, addrlen);
}
The gcc compiler (8.5.0) does not inline __sys_connect() in syscall entry
function. But latest clang trunk did the inlining. So the bpf program
is not triggered.
To make the test more reliable, let us kprobe the syscall entry function
instead. Note that x86_64, arm64 and s390 have syscall wrappers and they have
to be handled specially.
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210929033000.3711921-1-yhs@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/probe_user.c')
-rw-r--r-- | tools/testing/selftests/bpf/prog_tests/probe_user.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/probe_user.c b/tools/testing/selftests/bpf/prog_tests/probe_user.c index 95bd12097358..52fe157e2a90 100644 --- a/tools/testing/selftests/bpf/prog_tests/probe_user.c +++ b/tools/testing/selftests/bpf/prog_tests/probe_user.c @@ -3,7 +3,7 @@ void test_probe_user(void) { - const char *prog_name = "kprobe/__sys_connect"; + const char *prog_name = "handle_sys_connect"; const char *obj_file = "./test_probe_user.o"; DECLARE_LIBBPF_OPTS(bpf_object_open_opts, opts, ); int err, results_map_fd, sock_fd, duration = 0; @@ -18,7 +18,7 @@ void test_probe_user(void) if (!ASSERT_OK_PTR(obj, "obj_open_file")) return; - kprobe_prog = bpf_object__find_program_by_title(obj, prog_name); + kprobe_prog = bpf_object__find_program_by_name(obj, prog_name); if (CHECK(!kprobe_prog, "find_probe", "prog '%s' not found\n", prog_name)) goto cleanup; |