Re: [PATCH v2] tracing/uprobe: Add missing PID filter for uretprobe

Oleg Nesterov
2024-08-30T12:24:04Z

On 08/30, Oleg Nesterov wrote:
>
> - This patch won't fix all problems because uprobe_perf_filter()
> filters by mm, not by pid. The changelog/patch assumes that it
> is a "PID filter", but it is not.
>
> See https://lore.kernel.org/linux-trace-kernel/20240825224018.GD3906@redhat.com/

Let me provide another example.

spawn.c:

#include <spawn.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
int pid;
sleep(3); // wait for bpftrace to start
posix_spawn(&pid, argv[1], NULL, NULL, argv+1, NULL);
for (;;)
pause();
}

Now,

$ ./spawn /usr/bin/true &
bpftrace -p $! -e 'uprobe:/usr/lib64/libc.so.6:sigprocmask { printf("%d\n", pid); }'
[2] 212851
Attaching 1 probe...
212855
^C
$ ./spawn /xxxxxxxxxxxx &
bpftrace -p $! -e 'uprobe:/usr/lib64/libc.so.6:_exit { printf("%d\n", pid); }'
[3] 212860
Attaching 1 probe...
212865
^C

This patch can't help in this case.

Oleg.