Repository navigation
fix(libkernel): answer Windows reparse points that are not links - #8534
Conversation
lstat and readlink threw NotImplemented for every Windows reparse point other than a symbolic link or a drive junction. A tag without the name surrogate bit (cloud files, deduplication) does not stand for another path, so lstat now answers as stat does and readlink returns EINVAL, as FreeBSD does for a file that is not a link and as CPython's os.lstat and os.readlink do (bpo-37834). A name surrogate that is neither a symbolic link nor a junction (a mounted volume, a WSL link) is reported as the reparse point itself with the mode of its attributes, and readlink returns EINVAL. The tests set reparse tags with FSCTL_SET_REPARSE_POINT, one without the name surrogate bit and one with it. A compact /exe (WOF) file cannot serve as the fixture: on Windows 11 24H2 the WOF filter hides the reparse point from GetFileAttributesW and FileAttributeTagInfo alike. Windows refuses every open of an unhandled tag without FILE_FLAG_OPEN_REPARSE_POINT, so the test requires lstat to agree with stat rather than to succeed. mashingaan's boykopovar#6447 returned EINVAL for other reparse points without the tag check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
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.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
On the overlap with #7202 above: merging the two, git auto-merges this PR's Measured on Windows 11, MinGW-w64 GCC 15.2.0, Release,
The hazard is the same in either order: the line comes from this PR, so a rebase of #7202 onto it keeps it on the raw path too. Whichever lands second needs the |
|
@ycbuzi Thanks, the tag check and the CPython reference make this easy to follow, and nothing that works today changes. One request for the tests: both new fixtures After that, the bar is a full CI run with |
…fused for rights Both fixtures required FSCTL_SET_REPARSE_POINT to succeed; a user without the right would have aborted guest_filesystem and guest_kernel_sys. They now print that the checks are skipped and carry on, as the symbolic link checks do without Developer Mode. On this PC the control succeeds at medium integrity, so the checks ran both elevated and unelevated. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
@oneandonlydean Done in 338e2cb, on top of the fix so the delta stays visible: both fixtures now treat a refused Unelevated run, as asked: Windows 11 Home 10.0.26200.9711, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, What this does not show is the skip branch itself running: I have no account here for which the control is refused. |
|
Thanks, and sorry for the slow reply. 338e2cb does what I asked: a refused FSCTL_SET_REPARSE_POINT skips only those checks, and only for the two rights errors, the same way the symbolic-link checks already do. The medium-integrity run is a better answer than I expected, since it shows the checks run unelevated rather than being skipped. The fix commit is unchanged since I last read it. Because #8312 touched the same files, I ran the full workflow on this head: guest_filesystem and guest_kernel_sys passed on Linux and Windows, with 0 failures overall. Merging. |
What
lstatandreadlinkthrowNotImplementedfor every Windows reparse point other than a symbolic link or a drive junction, which terminates the title. A tag without the name-surrogate bit (cloud files, deduplication) does not stand for another path:lstatnow answers asstatdoes andreadlinkreturnsEINVAL, as FreeBSD's readlink(2) does for a file that is not a link and as CPython'sos.lstatandos.readlinkdo since 3.8 (bpo-37834). A name surrogate that is neither a symbolic link nor a junction (a mounted volume, a WSL link) is reported as the reparse point itself with the mode of its attributes, andreadlinkreturnsEINVAL.The tests create reparse points with
FSCTL_SET_REPARSE_POINTand a GUID buffer, one with tag0x00000ABC(no name-surrogate bit) and one with0x20000ABC. Acompact /exe(WOF) file cannot serve as the fixture: on Windows 11 24H2 the WOF filter hides the reparse point fromGetFileAttributesWandFileAttributeTagInfoalike, measured with a probe that sets, queries and clears tags. Windows refuses every open of an unhandled tag withoutFILE_FLAG_OPEN_REPARSE_POINT(ERROR_CANT_ACCESS_FILE), so the test requireslstatto agree withstaton that file rather than to succeed; a filter-handled tag opens normally and takes the same path.Related: mashingaan's #6447 (closed) returned
EINVALfor other reparse points without the tag check. #7202 (open) rewrites the samelstatblock ofNativeStat.cppfor long paths, and #8312 (open) changes another branch ofReadNativeLink(ENOTDIRthrough a regular file); each is independent in behaviour, so whichever lands second rebases. Thelstattechnical-debt entry loses only the clause this change makes false, keeping #7551'sO_NOFOLLOWsentence, and the non-link reparse points get an entry of their own so both stay under the length limit.Tested
Windows 11 24H2, MinGW-w64 GCC 15.2.0 (x86_64-ucrt-posix-seh r7), Release, on
maind073fe6 plus this commit, run elevated:guest_kernel_sysandguest_filesystempass.main'sWindowsSymbolicLink.hpp,NativeStat.cppandlibkernel_sys/Export.cppand the new tests kept, both fail (exit 0xc0000409); with the change both pass.main's ownguest_kernel_sysandguest_filesystempass against this change's code.runas /trustlevelexecutes nothing on this host, so whetherFSCTL_SET_REPARSE_POINTon a file the test owns needs elevation is unverified.Linux: the change is inside
#ifdef _WIN32; not run here.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code