Files
DroidDeck/tools/proot/patches/0003-clone3-flags-read-guard.patch
T
maxjivi05 b8fcef622e proot: build the runtime's proot from source with WinNative's performance fixes
The runtime carries Termux's proot 5.1.107-70 as a prebuilt binary, built from
termux/proot 4dba3afb (every file:line site in it matches that commit). The apk
now builds that same commit with the NDK, with three patches ported from
WinNative's feature/proot-enhancements, and prefers it over the runtime's copy:

- Tracees are hashed by pid, so each ptrace stop finds its tracee without
  walking a list of every thread, and terminated tracees are swept only after
  a termination.
- A clean absolute path three or more directories deep under the rootfs alone
  has its parent opened once and taken as canonical when the kernel's path for
  it is the one proot would build, instead of an lstat per component; the final
  component of a call that does not follow it is no longer lstat'ed. Extensions
  still see the parent's host path, and the f2fs workaround keeps the old walk.
- A clone3 thread keeps its inherited flags when clone_args cannot be read.

talloc is linked in statically from Samba's release tarball, so libproot.so
needs only libc and libdl. On an x86_64 Android 15 emulator the same build ran
a path and thread test suite with output identical to the unpatched commit
(fake id, fake root, link2symlink, with and without seccomp), and a stat-heavy
benchmark ran 25-27% faster, 31-36% with 1500 live threads.
2026-09-23 22:03:57 -04:00

31 lines
1.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: maxjivi05 <maxjividen@gmail.com>
Date: Wed, 23 Sep 2026 21:44:45 -0400
Subject: [PATCH] tracee: keep a thread's inherited clone flags when clone3's
arguments cannot be read
---
src/tracee/tracee.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/tracee/tracee.c b/src/tracee/tracee.c
index 90894a0..7c0c50c 100644
--- a/src/tracee/tracee.c
+++ b/src/tracee/tracee.c
@@ -423,10 +423,11 @@ int new_child(Tracee *parent, word_t clone_flags)
status = fetch_regs(parent);
if (status >= 0 && get_sysnum(parent, CURRENT) == PR_clone)
clone_flags = peek_reg(parent, CURRENT, SYSARG_1);
- else if (status >= 0 && get_sysnum(parent, CURRENT) == PR_clone3)
- // Look at the first word of the clone_args structure, which
- // contains the usual clone flags.
- clone_flags = peek_word(parent, peek_reg(parent, CURRENT, SYSARG_1));
+ else if (status >= 0 && get_sysnum(parent, CURRENT) == PR_clone3) {
+ word_t flags = peek_word(parent, peek_reg(parent, CURRENT, SYSARG_1));
+ if (errno == 0)
+ clone_flags = flags;
+ }
/* Get the pid of the parent's new child. */
status = ptrace(PTRACE_GETEVENTMSG, parent->pid, NULL, &pid);