libc: guest paths resolve ".." lexically, so stat/open/unlink/rmdir act on "missing/../file" instead of failing; fix branch ready #3117
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-10T22:35:11Z.
Resolveinlibc/src/General.cppnormalizes the guest path withlexically_normal()before the host sees it, so the component before..is never checked. On main (Linux), withdd/filea file anddd/victima directory:stat("dd/missing/../file")andopen(...)succeed;stat("dd/file/..")succeeds;unlink("dd/missing/../file")deletesdd/file;rmdir("dd/missing/../victim")deletesdd/victim.FreeBSD's
lookup()(sys/kern/vfs_lookup.c) resolves..withVOP_LOOKUPin the directory reached so far, so these fail with ENOENT (missing component) or ENOTDIR (file component), and POSIX pathname resolution (XBD 4.13) says the same.Fix on my fork:
milescoviello/AnyPS5:fix/dotdot-path-resolution(one commit,98a5a999, onmain4d27834f; the 12 commits onmainsince then don't touch these files):..is still collapsed when the path before it is an existing directory, so aliases and case-insensitive matching behave as before. Otherwise the rest of the path goes to the host unchanged, and Linux reports ENOENT/ENOTDIR as FreeBSD does. On Windows, Win32 collapses..itself, so results there are unchanged (not fixed, no regression).guest_filesystemgains checks (the negative ones inside its existing non-Windows block) that fail on main and pass with the fix. Windows was not built or tested.Setup: Gentoo, Linux 7.2.8, GCC 15.3.0, Release with CI's configure flags,
main4d27834f.Tested: the new checks fail on
mainand pass with the fix. Fullctestwith the fix on Linux (RTX 5090 Laptop GPU): no new failures; the only failures are the knownagc_driver_dcc_keys_first_write(#2767) and twoguest_video_out_*tests that time out with the displays powered off.tools/check_conventions.pypasses. All five fixes I am filing today also pass their tests merged together on the currentmain.Not opened as a PR because intake is paused for new contributors; a maintainer is welcome to carry the commit.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-11T01:18:44Z.
Windows run, since the issue says it wasn't built or tested there: Windows 11, WinLibs GCC 15.2.0 r7, Release,
fix/dotdot-path-resolution(98a5a999) merged ontomain06da1176together with #3116, #3181 and #3169.guest_filesystempasses (including the newviaParentcheck outside the non-Windows block), and all 421 non-GPU tests (ctest -E "^agc_") pass with the four branches merged. So no regression, as you expected.statandopenofroot/missing/../present.txtstill succeed,statofpresent.txt/..returns 0, andsceKernelStatofpresent.txt/../present.txtreturns 0, since Win32 collapses the..the branch hands it...isn't a directory, a\?\path makes Windows keep the..instead of collapsing it. I checked withos.stathere:\?\<dir>\missing\..\present.txtfails with ERROR_PATH_NOT_FOUND (3), which would give ENOENT. But\?\<dir>\present.txt\..fails with the same error 3, not a "not a directory" one, so the ENOTDIR cases would need their own check (for example, whether the part before..exists as a file).AI-assisted (Claude Code); I ran all of this on my machine.