]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Fix uprobe multi pid filter check
authorJiri Olsa <jolsa@kernel.org>
Thu, 5 Sep 2024 11:51:21 +0000 (14:51 +0300)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 5 Sep 2024 19:43:22 +0000 (12:43 -0700)
Uprobe multi link does its own process (thread leader) filtering before
running the bpf program by comparing task's vm pointers.

But as Oleg pointed out there can be processes sharing the vm (CLONE_VM),
so we can't just compare task->vm pointers, but instead we need to use
same_thread_group call.

Suggested-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Link: https://lore.kernel.org/bpf/20240905115124.1503998-2-jolsa@kernel.org
kernel/trace/bpf_trace.c

index b69a39316c0cecb39181692f99fb84c10879a76c..98e395f1baae20e45627b470f55c8be6e31e731f 100644 (file)
@@ -3207,7 +3207,7 @@ static int uprobe_prog_run(struct bpf_uprobe *uprobe,
        struct bpf_run_ctx *old_run_ctx;
        int err = 0;
 
-       if (link->task && current->mm != link->task->mm)
+       if (link->task && !same_thread_group(current, link->task))
                return 0;
 
        if (sleepable)