]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests/bpf: Rename uprobe_syscall_executed prog to test_uretprobe_multi
authorJiri Olsa <jolsa@kernel.org>
Sun, 20 Jul 2025 11:21:23 +0000 (13:21 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 21 Aug 2025 18:09:23 +0000 (20:09 +0200)
Renaming uprobe_syscall_executed prog to test_uretprobe_multi
to fit properly in the following changes that add more programs.

Plus adding pid filter and increasing executed variable.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20250720112133.244369-14-jolsa@kernel.org
tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c
tools/testing/selftests/bpf/progs/uprobe_syscall_executed.c

index a8f00aee779934aa2729e78aea319a63cfcba670..6d58a44da2b240c5585981d878bc24b03dcb595a 100644 (file)
@@ -252,6 +252,7 @@ static void test_uretprobe_syscall_call(void)
        );
        struct uprobe_syscall_executed *skel;
        int pid, status, err, go[2], c = 0;
+       struct bpf_link *link;
 
        if (!ASSERT_OK(pipe(go), "pipe"))
                return;
@@ -277,11 +278,14 @@ static void test_uretprobe_syscall_call(void)
                _exit(0);
        }
 
-       skel->links.test = bpf_program__attach_uprobe_multi(skel->progs.test, pid,
-                                                           "/proc/self/exe",
-                                                           "uretprobe_syscall_call", &opts);
-       if (!ASSERT_OK_PTR(skel->links.test, "bpf_program__attach_uprobe_multi"))
+       skel->bss->pid = pid;
+
+       link = bpf_program__attach_uprobe_multi(skel->progs.test_uretprobe_multi,
+                                               pid, "/proc/self/exe",
+                                               "uretprobe_syscall_call", &opts);
+       if (!ASSERT_OK_PTR(link, "bpf_program__attach_uprobe_multi"))
                goto cleanup;
+       skel->links.test_uretprobe_multi = link;
 
        /* kick the child */
        write(go[1], &c, 1);
index 0d7f1a7db2e2eccf025aa9322a068ba3d682bebc..8f48976a33aa598ddd276253da0112b8cc05e622 100644 (file)
@@ -8,10 +8,14 @@ struct pt_regs regs;
 char _license[] SEC("license") = "GPL";
 
 int executed = 0;
+int pid;
 
 SEC("uretprobe.multi")
-int test(struct pt_regs *regs)
+int test_uretprobe_multi(struct pt_regs *ctx)
 {
-       executed = 1;
+       if (bpf_get_current_pid_tgid() >> 32 != pid)
+               return 0;
+
+       executed++;
        return 0;
 }