mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Crash when attaching uretprobes to processes running in Docker
@ 2025-01-10 15:12 Eyal Birger
  2025-01-10 15:25 ` Aleksa Sarai
  0 siblings, 1 reply; 47+ messages in thread
From: Eyal Birger @ 2025-01-10 15:12 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: olsajiri, mhiramat, oleg, linux-kernel, linux-trace-kernel,
	BPF-dev-list, Song Liu, Yonghong Song, John Fastabend, peterz,
	tglx, bp, x86, linux-api, Andrii Nakryiko, Daniel Borkmann,
	Alexei Starovoitov, Andrii Nakryiko, rostedt, rafi,
	Shmulik Ladkani

Hi,

When attaching uretprobes to processes running inside docker, the attached
process is segfaulted when encountering the retprobe. The offending commit
is:

ff474a78cef5 ("uprobe: Add uretprobe syscall to speed up return probe")

To my understanding, the reason is that now that uretprobe is a system call,
the default seccomp filters in docker block it as they only allow a specific
set of known syscalls.

This behavior can be reproduced by the below bash script, which works before
this commit.

Reported-by: Rafael Buchbinder <rafi@rbk.io>

Eyal.

--- CODE ---
#!/bin/bash

cat > /tmp/x.c << EOF
#include <stdio.h>
#include <seccomp.h>

char *syscalls[] = {
"write",
"exit_group",
};

__attribute__((noinline)) int probed(void)
{
printf("Probed\n");
return 1;
}

void apply_seccomp_filter(char **syscalls, int num_syscalls)
{
scmp_filter_ctx ctx;

ctx = seccomp_init(SCMP_ACT_ERRNO(1));
for (int i = 0; i < num_syscalls; i++) {
seccomp_rule_add(ctx, SCMP_ACT_ALLOW,
seccomp_syscall_resolve_name(syscalls[i]), 0);
}
seccomp_load(ctx);
seccomp_release(ctx);
}

int main(int argc, char *argv[])
{
int num_syscalls = sizeof(syscalls) / sizeof(syscalls[0]);

apply_seccomp_filter(syscalls, num_syscalls);

probed();

return 0;
}
EOF

cat > /tmp/trace.bt << EOF
uretprobe:/tmp/x:probed
{
    printf("ret=%d\n", retval);
}
EOF

gcc -o /tmp/x /tmp/x.c -lseccomp

/usr/bin/bpftrace /tmp/trace.bt &

sleep 5 # wait for uretprobe attach
/tmp/x

pkill bpftrace

rm /tmp/x /tmp/x.c /tmp/trace.bt

^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2025-01-17 17:53 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-10 15:12 Crash when attaching uretprobes to processes running in Docker Eyal Birger
2025-01-10 15:25 ` Aleksa Sarai
2025-01-11 18:40   ` Jiri Olsa
2025-01-14  9:22     ` Jiri Olsa
2025-01-14 10:05       ` Masami Hiramatsu
2025-01-14 11:21         ` Oleg Nesterov
2025-01-14 14:21           ` Jiri Olsa
2025-01-17  1:23             ` Masami Hiramatsu
2025-01-17  1:57               ` Oleg Nesterov
2025-01-14 10:42       ` Peter Zijlstra
2025-01-14 11:01         ` Oleg Nesterov
2025-01-14 12:02           ` Peter Zijlstra
2025-01-14 12:32             ` Oleg Nesterov
2025-01-14 14:07               ` Peter Zijlstra
2025-01-14 17:43                 ` Oleg Nesterov
2025-01-14 10:58       ` Oleg Nesterov
2025-01-14 14:19         ` Jiri Olsa
2025-01-14 19:21           ` Andrii Nakryiko
2025-01-14 20:39             ` Oleg Nesterov
2025-01-14 21:45               ` Andrii Nakryiko
2025-01-14 22:10                 ` Oleg Nesterov
2025-01-14 23:52                   ` Andrii Nakryiko
2025-01-15  0:09                     ` Eyal Birger
2025-01-15  0:50                       ` Oleg Nesterov
2025-01-15  5:45                         ` Shmulik Ladkani
2025-01-15 15:51                           ` Oleg Nesterov
2025-01-17 11:41                 ` Peter Zijlstra
2025-01-17 17:53                   ` Andrii Nakryiko
2025-01-14 14:08       ` Eyal Birger
2025-01-14 14:33         ` Oleg Nesterov
2025-01-14 14:56           ` Jiri Olsa
2025-01-14 17:25             ` Oleg Nesterov
2025-01-15  9:36               ` Jiri Olsa
2025-01-15 13:24                 ` Eyal Birger
2025-01-15 13:25                 ` Jiri Olsa
2025-01-15 15:06                 ` Oleg Nesterov
2025-01-15 17:56                   ` Alexei Starovoitov
2025-01-15 18:20                     ` Andrii Nakryiko
2025-01-15 18:40                     ` Oleg Nesterov
2025-01-15 18:48                       ` Eyal Birger
2025-01-15 19:03                         ` Oleg Nesterov
2025-01-15 21:14                           ` Eyal Birger
2025-01-16 14:39                             ` Oleg Nesterov
2025-01-16 14:47                               ` Eyal Birger
2025-01-16 15:31                                 ` Oleg Nesterov
2025-01-16 17:11                                   ` Eyal Birger
2025-01-17  0:48                                     ` Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome