mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-07 16:17:41 -04:00
selftests/bpf: Add test for attaching uprobe with long event names
This test verifies that attaching uprobe/uretprobe with long event names does not trigger EINVAL errors. Signed-off-by: Feng Yang <yangfeng@kylinos.cn> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20250417014848.59321-3-yangfeng59949@163.com
This commit is contained in:
committed by
Andrii Nakryiko
parent
4dde20b1aa
commit
e1be7c45d2
@@ -122,6 +122,52 @@ static void test_attach_probe_manual(enum probe_attach_mode attach_mode)
|
||||
test_attach_probe_manual__destroy(skel);
|
||||
}
|
||||
|
||||
/* attach uprobe/uretprobe long event name testings */
|
||||
static void test_attach_uprobe_long_event_name(void)
|
||||
{
|
||||
DECLARE_LIBBPF_OPTS(bpf_uprobe_opts, uprobe_opts);
|
||||
struct bpf_link *uprobe_link, *uretprobe_link;
|
||||
struct test_attach_probe_manual *skel;
|
||||
ssize_t uprobe_offset;
|
||||
char path[PATH_MAX] = {0};
|
||||
|
||||
skel = test_attach_probe_manual__open_and_load();
|
||||
if (!ASSERT_OK_PTR(skel, "skel_kprobe_manual_open_and_load"))
|
||||
return;
|
||||
|
||||
uprobe_offset = get_uprobe_offset(&trigger_func);
|
||||
if (!ASSERT_GE(uprobe_offset, 0, "uprobe_offset"))
|
||||
goto cleanup;
|
||||
|
||||
if (!ASSERT_GT(readlink("/proc/self/exe", path, PATH_MAX - 1), 0, "readlink"))
|
||||
goto cleanup;
|
||||
|
||||
/* manual-attach uprobe/uretprobe */
|
||||
uprobe_opts.attach_mode = PROBE_ATTACH_MODE_LEGACY;
|
||||
uprobe_opts.ref_ctr_offset = 0;
|
||||
uprobe_opts.retprobe = false;
|
||||
uprobe_link = bpf_program__attach_uprobe_opts(skel->progs.handle_uprobe,
|
||||
0 /* self pid */,
|
||||
path,
|
||||
uprobe_offset,
|
||||
&uprobe_opts);
|
||||
if (!ASSERT_OK_PTR(uprobe_link, "attach_uprobe_long_event_name"))
|
||||
goto cleanup;
|
||||
skel->links.handle_uprobe = uprobe_link;
|
||||
|
||||
uprobe_opts.retprobe = true;
|
||||
uretprobe_link = bpf_program__attach_uprobe_opts(skel->progs.handle_uretprobe,
|
||||
-1 /* any pid */,
|
||||
path,
|
||||
uprobe_offset, &uprobe_opts);
|
||||
if (!ASSERT_OK_PTR(uretprobe_link, "attach_uretprobe_long_event_name"))
|
||||
goto cleanup;
|
||||
skel->links.handle_uretprobe = uretprobe_link;
|
||||
|
||||
cleanup:
|
||||
test_attach_probe_manual__destroy(skel);
|
||||
}
|
||||
|
||||
static void test_attach_probe_auto(struct test_attach_probe *skel)
|
||||
{
|
||||
struct bpf_link *uprobe_err_link;
|
||||
@@ -323,6 +369,9 @@ void test_attach_probe(void)
|
||||
if (test__start_subtest("uprobe-ref_ctr"))
|
||||
test_uprobe_ref_ctr(skel);
|
||||
|
||||
if (test__start_subtest("uprobe-long_name"))
|
||||
test_attach_uprobe_long_event_name();
|
||||
|
||||
cleanup:
|
||||
test_attach_probe__destroy(skel);
|
||||
ASSERT_EQ(uprobe_ref_ctr, 0, "uprobe_ref_ctr_cleanup");
|
||||
|
||||
Reference in New Issue
Block a user