fix(proot): fchdir takes the open directory's path instead of walking it again (#2553)

* fix(proot): fchdir takes the open directory's path instead of walking it again

* fix(proot): fchdir keeps trailing-period names and rechecks the binding's parent

The descriptor path now carries the same final marker the walk produced, so a directory whose name ends with a period is not truncated. The parent of the matching binding is resolved again, so a binding whose ancestor was replaced by a symlink takes the full walk as before. The check script gains a trailing-period directory.

* fix(proot): fchdir requires the binding's parent to be a directory
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-13 00:55:18 -05:00
1 parent bb05e20d1b
commit f33181e430
4 files changed
+226 -1

No files matched your search

+12
View File
@@ -170,6 +170,18 @@ Prototype (inert unless `PROOT_FASTPATH` is set; see `docs/development/proot-per
Old kernel fixes:
- `0028-fchdir-open-directory.patch` - `fchdir` resolved the directory again from its guest path,
one `lstat` per path component, then an `lstat` and an `O_PATH` open of the result. The
descriptor is already open, so `/proc/<pid>/fd/<n>` gives its host path and one `stat` through
that link confirms it is a live directory. The guest path it maps to is checked to map back to
the same host path, and the parent of the binding it falls under is checked to still resolve
to itself, so the cwd PRoot records is the one the old walk produced; a deleted directory, a
path outside the guest, a binding whose ancestor became a symlink, or anything else that does
not round-trip takes the old walk. Listing a directory in Wine does `fchdir` there and back: on a memory card behind
Android's FUSE daemon the old walk cost about 4 ms per call in the single tracer thread, 8.4 s
of an 8.8 s tracer total across one program start, and is now under 0.1 ms.
`bench/fchdir.py [directory...]` checks the cwd after `fchdir` to plain, bound, symlinked,
renamed and deleted directories and prints the per-call cost.
- `0015-lost-fork-events.patch` - works around a problem reported on Xiaomi's msm 4.14 kernel:
the kernel sometimes reports a new process or thread but gives its ID as zero. Without that ID,
PRoot cannot finish setting it up, which can leave the session stuck. The patch searches `/proc`