Skip to content

Commit cf6cb56

Browse files
ebirgerkees
authored andcommitted
seccomp: passthrough uretprobe systemcall without filtering
When attaching uretprobes to processes running inside docker, the attached process is segfaulted when encountering the retprobe. 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 is true for other userspace applications which use seccomp to control their syscall surface. Since uretprobe is a "kernel implementation detail" system call which is not used by userspace application code directly, it is impractical and there's very little point in forcing all userspace applications to explicitly allow it in order to avoid crashing tracked processes. Pass this systemcall through seccomp without depending on configuration. Note: uretprobe is currently only x86_64 and isn't expected to ever be supported in i386. Fixes: ff474a7 ("uprobe: Add uretprobe syscall to speed up return probe") Reported-by: Rafael Buchbinder <rafi@rbk.io> Closes: https://lore.kernel.org/lkml/CAHsH6Gs3Eh8DFU0wq58c_LF8A4_+o6z456J7BidmcVY2AqOnHQ@mail.gmail.com/ Link: https://lore.kernel.org/lkml/20250121182939.33d05470@gandalf.local.home/T/#me2676c378eff2d6a33f3054fed4a5f3afa64e65b Link: https://lore.kernel.org/lkml/20250128145806.1849977-1-eyal.birger@gmail.com/ Cc: stable@vger.kernel.org Signed-off-by: Eyal Birger <eyal.birger@gmail.com> Link: https://lore.kernel.org/r/20250202162921.335813-2-eyal.birger@gmail.com [kees: minimized changes for easier backporting, tweaked commit log] Signed-off-by: Kees Cook <kees@kernel.org>
1 parent 2014c95 commit cf6cb56

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

kernel/seccomp.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,15 @@ static bool seccomp_is_const_allow(struct sock_fprog_kern *fprog,
749749
if (WARN_ON_ONCE(!fprog))
750750
return false;
751751

752+
/* Our single exception to filtering. */
753+
#ifdef __NR_uretprobe
754+
#ifdef SECCOMP_ARCH_COMPAT
755+
if (sd->arch == SECCOMP_ARCH_NATIVE)
756+
#endif
757+
if (sd->nr == __NR_uretprobe)
758+
return true;
759+
#endif
760+
752761
for (pc = 0; pc < fprog->len; pc++) {
753762
struct sock_filter *insn = &fprog->filter[pc];
754763
u16 code = insn->code;
@@ -1023,6 +1032,9 @@ static inline void seccomp_log(unsigned long syscall, long signr, u32 action,
10231032
*/
10241033
static const int mode1_syscalls[] = {
10251034
__NR_seccomp_read, __NR_seccomp_write, __NR_seccomp_exit, __NR_seccomp_sigreturn,
1035+
#ifdef __NR_uretprobe
1036+
__NR_uretprobe,
1037+
#endif
10261038
-1, /* negative terminated */
10271039
};
10281040

0 commit comments

Comments
 (0)