Repository navigation
fix: keep CLONE_VM and CLONE_VFORK on vfork-style clones - #56
Merged
Merged
Conversation
Both are built with the distro's cc, so they use its libc. posix_spawn of a missing program must return ENOENT; with proot stripping CLONE_VM and CLONE_VFORK, glibc returned 0 and the child exited 127. vfork + exec of a real and a missing program must return to the parent; the test runs under timeout 20 so a vfork that never returns fails instead of hanging the suite.
The T8.1 handler stripped CLONE_VM and CLONE_VFORK from every clone without CLONE_THREAD, turning vfork-style spawns into forks. glibc's posix_spawn reports a failed exec through memory the child shares with the parent while the parent waits for the vfork, so with the flags gone it returned 0 for a program that does not exist, and Rust's Command::spawn returned Ok. musl reports through a pipe and was not affected. The vfork hang the stripping worked around no longer reproduces: vfork + exec, posix_spawn, cargo build and run, apt-get, and the full suite on Ubuntu and Alpine pass with the flags kept, as in upstream and Termux proot. The SIGSYS path for devices that block clone or clone3 is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Audit P7, verified on the device first.
Since T8.1 (2026-04), proot's ptrace path stripped
CLONE_VM | CLONE_VFORKfrom everyclone/clone3withoutCLONE_THREAD, turning vfork-style spawns into forks to work around a vfork hang. glibc'sposix_spawnreports a failed exec through memory the child shares with the parent, while the parent waits for the vfork. With the flags gone it returned 0 for a program that does not exist, and the child exited 127. Rust'sCommand::spawnandoutput()returnedOk, so cargo, build scripts and tool probes on glibc distros saw "started, exit 127" instead of "not found". musl reports through a pipe, so Alpine was unaffected.posix_spawn("/nonexistent-prog")ENOENTposix_spawnp("nonexistent-prog")ENOENTCommand::new("/nonexistent-prog").spawn()Ok, exit 127Err(NotFound)Upstream proot and Termux's proot pass these flags through, and our vfork event handling is the same as Termux's. With the stripping removed, the hang it worked around no longer reproduces.
src/proot/src/syscall/enter.c: thePR_clone/PR_clone3enter handlers that stripped the flags are removed. The SIGSYS path (tracee/seccomp.c), used only on devices whose filter blocksclone/clone3, is unchanged (audit P1 covers it).libproot.sorebuilt from source with NDK r27c (a clean build; the loader is unchanged).cc:posix_spawnof a missing program must beENOENT, andvfork+ exec (of a real and a missing program) must return to the parent, undertimeout 20so a hang fails rather than blocking the suite.libpr-cli.sorebuilt to embed them.proot-improvement.md(PR_clone/PR_clone3), a note in the historicalrust-toolchain-support.md,integration-tests.md, README and AGENTS.md (59 tests, 68 runs).Tests
On an Android 17 device:
posix_spawn of a missing program is ENOENTfails withrc=0.cargo build, with and without git).posix_spawn/posix_spawnp; a Rust program spawning a missing program (NotFound), capturing a child's output and exit code, and running threads;cargo new,cargo buildandcargo run;apt-get install/removeof a package with maintainer scripts. None of them hang.cargo clippy -D warningsandcargo fmt --checkclean for the test binary.