Repository navigation
fix: fake root hides only EPERM, EACCES and a masked ENOENT from utime calls - #57
Merged
Merged
Conversation
A fakeroot test sets the times of an existing file, then expects EINVAL for invalid flags, EBADF for a closed fd and EBADF for a relative path under a closed dirfd. fake_id0's utime exit handler turned every error into 0, so utimensat with bad flags succeeded.
Under fake root the utimensat/utimes/futimesat/utime exit handler turned every error into 0, for dpkg and tar on link2symlink paths where SELinux reports ENOENT. EBADF, EINVAL, EROFS, ENOTDIR and the rest became success too. Only EPERM, EACCES and an ENOENT for a target that exists are hidden now; other errors pass through, and a real ENOENT for a missing target still reaches touch(1).
read_string returns PATH_MAX both for a string that fills the buffer and for one cut off without a NUL; utime_target_missing accepted it and could lstat an unterminated buffer. It now rejects it, as the rest of proot does. A guest path that long fails translation with ENAMETOOLONG first, so this guards rather than fixes a reachable bug.
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 P8 and P4, in
extension/fake_id0/fake_id0.c.P8. Under fake root (euid 0), the exit handler for
utimensat/utimes/futimesat/utimeturned every error into 0. It exists so dpkg and tar can set times on link2symlink paths, where SELinux masks the result asENOENT(important-notes.md, Failure 1). ButEBADF,EINVAL,EROFS,ENOTDIRand the rest became success too:utimensatwith invalid flags returned 0. Nowutime_error_hidden()hides onlyEPERM,EACCESand anENOENTfor a target that exists. A realENOENTfor a missing target still reachestouch(1), and everything else passes through.P4.
utime_target_missing()accepted aread_string()result of exactlyPATH_MAX, which can be a buffer without a NUL, thenlstated it. It now rejects that, as the rest of proot does (>= PATH_MAX). A guest path that long fails translation withENAMETOOLONGbefore this runs, so this is a guard rather than a reachable bug, and has no test of its own.EINVAL, a closed fdEBADF, a relative path under a closed dirfdEBADF.libproot.sorebuilt (NDK r27c);libpr-cli.sorebuilt to embed the test.proot-improvement.md§28,important-notes.md,integration-tests.md, README and AGENTS.md (60 tests, 69 runs).Tests
On an Android 17 device:
utimensat with invalid flags: rc=0 errno=9, want errno 22.apt-get installandremoveof a package in Ubuntu (dpkg sets times while unpacking), andtouchcreating a new file and updating an existing one.cargo clippy -D warningsandcargo fmt --checkclean.