From be0fe352713c7567f8d9adc78034e18179ebbd7c Mon Sep 17 00:00:00 2001 From: MaxsTechReview Date: Sat, 7 Nov 2026 15:48:44 -0500 Subject: [PATCH] fix(proot): let the fast path fall back when Android 10 refuses statx (#2224) --- tools/proot/PATCHES.md | 10 ++++ tools/proot/bench/statx-trap.c | 32 +++++++++++ ...25-fastpath-trampoline-sigsys-enosys.patch | 57 +++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 tools/proot/bench/statx-trap.c create mode 100644 tools/proot/patches/0025-fastpath-trampoline-sigsys-enosys.patch diff --git a/tools/proot/PATCHES.md b/tools/proot/PATCHES.md index dbf1b959b..ddb3278d7 100644 --- a/tools/proot/PATCHES.md +++ b/tools/proot/PATCHES.md @@ -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 (`//...`) 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: diff --git a/tools/proot/bench/statx-trap.c b/tools/proot/bench/statx-trap.c new file mode 100644 index 000000000..fab7bd5ee --- /dev/null +++ b/tools/proot/bench/statx-trap.c @@ -0,0 +1,32 @@ +#include "../fastpath/fastpath.c" +#include "checks.h" +#include +#include +#include + +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; +} diff --git a/tools/proot/patches/0025-fastpath-trampoline-sigsys-enosys.patch b/tools/proot/patches/0025-fastpath-trampoline-sigsys-enosys.patch new file mode 100644 index 000000000..d9d02f928 --- /dev/null +++ b/tools/proot/patches/0025-fastpath-trampoline-sigsys-enosys.patch @@ -0,0 +1,57 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: maxjivi05 +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");