Repository navigation
fix(filesystem): reject invalid parent traversal on Windows - #3485
Conversation
|
Thanks @santhoshkumar-dev for carrying my commit with its authorship and adding the Windows half. Native Linux run of this PR's head (
AI-assisted: yes |
|
Rebased onto current |
f50a5fa to
2c1eb02
Compare
|
@adriadam10 the |
|
Thank you all:
On CI: agreed with milescoviello, the only failing check is AI-assisted: yes (Claude Code) |
|
@santhoshkumar-dev here's a Windows run of the rebased head, since my earlier run in #3117 was only of the first commit (it showed
To get there I had to add two things that aren't about this PR, because both tests fail on Windows on
Both merged onto this PR without conflicts (#3510 also changes One gap, from AI-assisted (Claude Code); I ran all of this on my machine. |
symlink, added in boykopovar#3491 while this branch was open, still resolved its new path with ResolvePath_nid_no_patch, which now throws for an invalid "..". Use ResolvePathError_nid_no_patch as link does, so "missing/../x" returns ENOENT and "file/../x" ENOTDIR. Reported by @Silverash-i8 on boykopovar#3485. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @Silverash-i8 for the Windows run of the rebased head and for catching
One note for #3510, not this PR: on this machine Developer Mode is on, so its AI-assisted: yes (Claude Code) |
|
@santhoshkumar-dev #3511 is in ( |
symlink, added in boykopovar#3491 while this branch was open, still resolved its new path with ResolvePath_nid_no_patch, which now throws for an invalid "..". Use ResolvePathError_nid_no_patch as link does, so "missing/../x" returns ENOENT and "file/../x" ENOTDIR. Reported by @Silverash-i8 on boykopovar#3485. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1216b7f to
548bedd
Compare
|
@milescoviello thanks, that was it. Rebased onto @adriadam10 thanks for the earlier rebase. Since then the branch gained one commit, AI-assisted: yes (Claude Code) |
|
@adriadam10 friendly ping: the branch is rebased onto On the overlap note with #3510: since its update ( AI-assisted: yes (Claude Code) |
Guest paths were normalized lexically before they reached the host, so "missing/../file" and "file/../x" dropped the component before "..": stat and open succeeded on the file, unlink deleted it and rmdir removed a directory, where FreeBSD's lookup() resolves ".." with VOP_LOOKUP in the directory reached so far and fails with ENOENT for a missing component and ENOTDIR for a file. POSIX path resolution (XBD 4.13) says the same. ".." is still collapsed lexically when the path before it is an existing directory, so case-insensitive matching and aliases behave as before. When it is not, the rest of the path is passed to the host unchanged and the host resolves it. Linux then reports ENOENT or ENOTDIR as FreeBSD does; Windows collapses ".." itself, so its results are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XYhZu5HokHMo9mfi8QU83m
symlink, added in boykopovar#3491 while this branch was open, still resolved its new path with ResolvePath_nid_no_patch, which now throws for an invalid "..". Use ResolvePathError_nid_no_patch as link does, so "missing/../x" returns ENOENT and "file/../x" ENOTDIR. Reported by @Silverash-i8 on boykopovar#3485. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
548bedd to
2ad9165
Compare
|
Rebased onto I rechecked the remaining direct
AI-assisted: yes (Claude Code) |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
|
@oneandonlydean could you take a look at this one as well when you have a moment? It's rebased onto current I also have a performance improvement ready on another branch, which I can only open once this lands because of the one-open-PR limit. AI-assisted: yes (Claude Code) |
|
Checked the current head on Linux merged onto |
|
Checked the diff on 2ad9165: the resolver's error reaches every entry point in its own error style, and the One thing I'm checking alongside it: a title that opens |
|
Thanks for checking that case, @oneandonlydean, and thanks @santhoshkumar-dev for carrying the commit. ENOENT there is what FreeBSD returns for a missing component, but a directory that exists on the console and not in our host layout would hit it too. If one of the titles does, I'm glad to look at its path log and follow up, for example by creating that directory in the layout or keeping the old behaviour for that prefix. AI-assisted: yes |
What
Fixes #3117. A guest path such as
missing/../present.txtcurrently reachespresent.txton Windows, so an invalid open, truncate, rename or unlink can operate on the real target. Validate the directory before removing a parent component and returnENOENTfor a missing component orENOTDIRfor a file component.Carries milescoviello's original Linux fix (
98a5a9991bf2990173d2d137515d0ef6206b2535) with authorship preserved, then adds Windows validation and error propagation. The existing branch left invalid components for the host to reject; Win32 normalizes those components again. Filesystem entry points now translate resolver failures into their guest errors. APR, AvPlayer and font loading preserve their existing failure results. A failedfreopenalso closes the original stream.The regressions check invalid and valid traversal, case matching, guest working directories, mount aliases, symlinks where available, missing-leaf creation, and preservation of existing files/directories after failed writes. Native Windows drive/UNC paths retain their existing bypass; host directory symlink parent traversal remains lexical.
Tested
Rebased on
mainat0f863c102.guest_filesystemandguest_kernel_syscases fail withmain's production files and pass with the fix.ctest: 833 of 836 pass, 5 skipped. The 3 failures (windows_exceptions,agc_driver_lds_mixed_width_atomics,agc_driver_pixel_interlock) fail the same way with this PR's 16 files reverted tomain: an exception throughstd::call_onceand two GPU results on this card.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code