fix(proot): let the fast path fall back when Android 10 refuses statx (#2224)

This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-07 15:48:44 -05:00
1 parent 7f0427b830
commit be0fe35271
3 files changed
+99

No files matched your search

+10
View File
@@ -132,6 +132,16 @@ Prototype (inert unless `PROOT_FASTPATH` is set; see `docs/development/proot-per
path, and PRoot refused the call unless the descriptor was `AT_FDCWD`. FEX starts every child of an
emulated program with `execveat(fd, "/proc/self/exe")`, so x86 programs in a Flatpak sandbox, which
does not carry the session's preloads, could not start other programs.
- `0025-fastpath-trampoline-sigsys-enosys.patch` - Android 10 and older refuse `statx` with
`SIGSYS`. A `statx` from the fast path's trampoline page already carries the host path, but
proot's `SIGSYS` emulation translated it again as a guest path (`<rootfs>/<rootfs>/...`) and
returned `ENOENT`, so every existing file looked missing to Rust's `metadata` and GNU `stat`:
uutils `mkdir -p` on an existing directory failed with "Already exists" and Steam setup stopped
(Pico 4, Android 10). A refused syscall from the trampoline now gets `ENOSYS` without
translation or extension handling, and the fast path falls back as it already does for
`statx` (`newfstatat`) and `memfd_create`. Syscalls outside the trampoline and sessions
without `PROOT_FASTPATH` are unchanged. `bench/statx-trap.c` traps `statx` and checks an
existing directory still reads as one.
Old kernel fixes:
+32
View File
@@ -0,0 +1,32 @@
#include "../fastpath/fastpath.c"
#include "checks.h"
#include <linux/filter.h>
#include <linux/seccomp.h>
#include <sys/prctl.h>
static void expect_dir(const char *path) {
struct statx stx;
memset(&stx, 0, sizeof stx);
long rs = fp_statx(AT_FDCWD, path, 0, STATX_BASIC_STATS, &stx);
if (rs != 0) fprintf(stderr, "statx %s: %s\n", path, strerror((int)-rs));
assert(rs == 0 && S_ISDIR(stx.stx_mode));
}
int main(int argc, char **argv) {
assert(argc == 2);
if (!fp_ready()) return 77;
struct sock_filter code[] = {
BPF_STMT(BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, nr)),
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SYS_statx, 0, 1),
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_TRAP),
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW),
};
struct sock_fprog filter = {.len = sizeof code / sizeof *code, .filter = code};
if (sc(SYS_prctl, PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) ||
sc(SYS_prctl, PR_SET_SECCOMP, SECCOMP_MODE_FILTER, (long)&filter, 0, 0)) return 77;
expect_dir("/");
expect_dir(argv[1]);
expect_dir(argv[1]);
puts("PASS: statx refused by the host policy still answers an existing guest directory");
return 0;
}
@@ -0,0 +1,57 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: maxjivi05 <maxjividen@gmail.com>
Date: Sat, 7 Nov 2026 12:00:00 -0500
Subject: [PATCH] fastpath: answer a host-refused trampoline syscall with ENOSYS
instead of translating its host path again
---
--- a/src/syscall/seccomp.c
+++ b/src/syscall/seccomp.c
@@ -812,6 +812,16 @@
return 0;
}
+bool from_fastpath_stub(const Tracee *tracee)
+{
+ word_t pc;
+
+ if (!fastpath_enabled())
+ return false;
+ pc = peek_reg(tracee, CURRENT, INSTR_POINTER);
+ return pc >= FASTPATH_STUB_ADDR && pc < FASTPATH_STUB_ADDR + FASTPATH_STUB_SIZE;
+}
+
word_t filtered_sysnum_flags(const Tracee *tracee, Sysnum sysnum)
{
static word_t flags[PR_NB_SYSNUM];
--- a/src/syscall/seccomp.h
+++ b/src/syscall/seccomp.h
@@ -45,5 +45,6 @@
extern int enable_syscall_filtering(const Tracee *tracee);
extern word_t filtered_sysnum_flags(const Tracee *tracee, Sysnum sysnum);
+extern bool from_fastpath_stub(const Tracee *tracee);
#endif /* SECCOMP_H */
--- a/src/tracee/seccomp.c
+++ b/src/tracee/seccomp.c
@@ -12,6 +12,7 @@
#include "cli/note.h"
#include "syscall/chain.h"
#include "syscall/syscall.h"
+#include "syscall/seccomp.h"
#include "tracee/seccomp.h"
#include "tracee/mem.h"
#include "tracee/statx.h"
@@ -123,6 +124,11 @@
sysnum = get_sysnum(tracee, CURRENT);
+ if (from_fastpath_stub(tracee)) {
+ set_result_after_seccomp(tracee, -ENOSYS);
+ return 0;
+ }
+
status = notify_extensions(tracee, SIGSYS_OCC, 0, 0);
if (status < 0) {
VERBOSE(tracee, 4, "SIGSYS errored out when being handled by an extension");