Repository navigation
fix(libc): pass long host paths relative to the root so macOS accepts guest paths up to PATH_MAX - #22932
fix(libc): pass long host paths relative to the root so macOS accepts guest paths up to PATH_MAX#22932Romannachwievor wants to merge 4 commits into
Conversation
Jazeupoi
left a comment
There was a problem hiding this comment.
Tested head b8276aee13 on the M4 with a full build: macOS 27.0.1, Apple clang 21.0.0, x86_64 Release under Rosetta. I merged it into my macOS base (main 57f7016922 with #17425 and #11049), which brings in main up to 3055e5830c.
guest_kernel_sysandguest_kernel_sys_execve: pass 3/3.- All non-AGC tests (
ctest -j6 -E '^agc_', 4011 tests): 12 failures. Eleven of them are the ones in my run ofe7de7040e0on the issue (nkwebkit_affinetransformguestpointersnow passes, since #22859 is inmain). The new one,guest_refused_connect, also fails with this commit reverted on the same tree, so it comes frommain, not from this change.
AI-assisted: yes (Claude Code)
|
Linux check of
I haven't looked into the two failures. They fail the same way without this change, and the container runs x86_64 through Rosetta, so they may come from the emulation rather than from Linux. AI-assisted: yes (Claude Code) |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — changes requested
Changes are required before merge: preserve guest-root containment when resolving paths whose host form exceeds PATH_MAX.
What I ran
Reviewed head b8276aee1364d46ad2ba0db3e04bdf3e845934d8 using the prepared review bundle and the pinned repository reader. No build or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Diff and changed files | passed | Both changed files read |
| Targeted source review | passed | Path resolution and chdir inspected |
| Build and tests | not run | Author-reported results were not rerun |
Findings
Blocking
core/libs/prx/libc/src/General.cpp:379: For long paths,HostPathcallsResolveHostPath({}, names, module)with an empty root.ResolveHostPathhandles..components by appending them to that root, so a guest path such as/../outsidecan resolve to a host path outside the emulator root. The short-path route retains the root and the laterSetWorkingDirectorycontainment check, but this branch can pass the escaped path to filesystem operations without that check. Keep resolution anchored to the emulator root while avoiding an overlong absolute syscall path, and ensure..cannot escape the guest root.
Non-blocking
None.
Not verified
- No build, tests, or runtime checks were run; the macOS and cross-platform results in the description are author-reported.
- The changed files read were
core/libs/prx/libc/src/General.cppanddocs/dev/debt/changes/fix-libc-macos-long-host-paths.md.files.jsonwas unavailable through the reader, so excluded files and the complete reviewed-file manifest were not independently confirmed.
To get this to a good state
Keep long-path resolution within the guest root, including paths containing .., then rerun the path tests that cover long paths and traversal.
|
Thanks for the review. I don't think
The empty root in line 379 makes the host path relative to the host working directory. That directory is the emulator root: The new check is in
Host symlinks under the root are followed the same way in both branches. This change doesn't touch that. AI-assisted: yes (Claude Code) |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — comments
The changed path handling has a potentially incorrect canonicalization edge case, and the reported tests were not run during this review.
What I ran
Reviewed head 1933d3d41da6ce2beaa8509cfe782ed3316b4819 using the prepared diff.patch and the pinned reader repo_read.py. No commands or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Diff and targeted source review | passed | All three changed files were read |
| Tests | not run | Author-reported results were not independently checked |
Findings
Blocking
None verified.
Non-blocking
core/libs/prx/libc/src/General.cpp:545— absolute resolved paths bypass the long-path handling.CanonicalHostPathimmediately callscanonical(resolved)whenresolvedis absolute. If an alias or provided path resolves to an absolute host path at or beyond the host path limit,chdirstill fails during canonicalization. The description explicitly leaves alias paths as open debt; consider documenting this limitation alongside the helper or adding a test to ensure this route remains intentionally unsupported.
Not verified
- No tests or builds were run. The test results in
description.mdare author-reported. - Linux and Windows behavior was not run.
- Read:
core/libs/prx/libc/src/General.cpp,core/libs/tests/GuestKernelSys.cpp, anddocs/dev/debt/changes/fix-libc-macos-long-host-paths.md(all changed files listed inmanifest.json). The prepared artifacts read weredescription.md,commits.md,manifest.json, anddiff.patch. No changed files were excluded.
To get this to a good state
Nothing is required. The alias path limitation is optional feedback.
|
Thanks. That limitation is intentional for now and already in the debt fragment: a path under an alias such as AI-assisted: yes (Claude Code) |
1933d3d to
dc77871
Compare
|
Rebased at head On the M1, isolated I also measured AI-assisted: yes (Claude Code) |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — comments
The review covers the changed implementation, test, and debt note at head dc77871833c7ee122a53baaf4f2b4eb6fd6b9560; a potential edge case in root-relative chdir handling merits clarification before a formal decision.
What I ran
- Read the prepared description, commit list, manifest, diff, and all three changed files at the pinned head.
- No commands or tests were run in this review.
Results
| Check | Result | Note |
|---|---|---|
| Changed files read | passed | All 3 reviewed files read |
| Tests run | not run | Author-reported results only |
| Excluded files | not applicable | Manifest lists no exclusions |
Findings
Blocking
None.
Non-blocking
- The new test constructs a path with enough leading
../components to climb past the emulator root, then expectsmkdiratto createinsidewithin that root. The relevant changed test lines arecore/libs/tests/GuestKernelSys.cpp:1453-1457. Please clarify how this exercises the stated root containment behavior, since itsclimb + insidepath appears to leave the root before resolvinginside.
Not verified
- No tests, build, or checks were run. The reported macOS test outcomes and CI report were not independently verified.
- Only the three changed files were read; repository callers and platform behavior beyond the targeted code were not verified.
files.jsonwas not available through the review-folder reader; the manifest shows all three changed files included and no excluded files.
To get this to a good state
Nothing is required. The optional test-path clarification above is the only comment.
|
@MarcZX10 thanks for the question, and the Windows job failure at line 1456 needed a fix too. Head is now How the test checks containment. Windows failure. Before the rebase, Tested
AI-assisted: yes (Claude Code) |
|
Windows run at d6cde1f. It works on Windows. The new long-path route cannot be exercised on Windows, so this run checks two things: that Windows behaves as before, and that the new test hunk, which now runs on Windows, passes there and is sensitive to What Windows exercises At head,
M1 and M3 below confirm that the first change makes no difference on Windows. M2 confirms that the moved check is still tested.
MarcZX10's question at dc77871 asks how the As a probe (P1), I made Tests Head d6cde1f merged cleanly onto main 38d22ef as fbbf41c884. The focused set is 48 path and directory tests, run with Two results are the same on every tree, so they are left out of the table below:
Mutations and probe Each one is a rebuild of the merge, followed by the focused set. All of them built.
Checks
Host
AI-assisted: yes |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — comments
The change addresses absolute guest paths whose host form exceeds PATH_MAX; review is incomplete because one changed source file’s added lines were not all read, and no checks were run.
What I ran
Inspected prepared diff and source at head d6cde1fdd63b2f2b6e69190fb05b9238eed2883e using repo_read.py review-folder and source-reading tools. No build or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Diff and targeted source review | passed | Core path handling inspected |
| Build and tests | not run | No local execution |
| All added lines read | not run | Some changed lines remain unread |
Findings
Blocking
None verified.
Non-blocking
- The test addition exercises
mkdiratandunlinkatwith a path containing leading..components, but the debt entry states descriptor-based*atcalls remain limited for long host paths. Consider adding a focused test or clarifying which*atcase this regression test covers. The test additions are atcore/libs/tests/GuestKernelSys.cpp:1453-1463.
Not verified
- I read changed lines in
core/libs/prx/libc/src/General.cpp,core/libs/tests/GuestKernelSys.cpp, anddocs/dev/debt/changes/fix-libc-macos-long-host-paths.md, but did not read every added line listed in the manifest. In particular, changed lines inGeneral.cppoutside the inspected ranges were not all reviewed. - Builds, tests, Linux behavior, and Windows behavior were not independently verified. The test results in the description are author-reported.
files.jsonwas not available as a review-folder document; the manifest lists all three changed files as included.
To get this to a good state
Nothing is required. Optional: clarify the *at test coverage noted above.
|
@MarcZX10 The new hunk passes The AI-assisted: yes (Claude Code) |
malekaifa
left a comment
There was a problem hiding this comment.
Reviewed exact head d6cde1fdd63b2f2b6e69190fb05b9238eed2883e, including the earlier guest-root containment concern.
The long-host-path route no longer creates a guest escape. Resolve() normalizes path components before HostPath: a .. only pops when the normalized component stack is non-empty, so leading/excess .. stop at the guest root and never reach ResolveHostPath({}, names, ...). For a path whose root-prefixed host spelling reaches PATH_MAX, the resulting normalized component vector is resolved relative to the process CWD, which is the emulator root for normal execution; the invariant is unchanged until LoadExec replaces the process. CanonicalHostPath likewise canonicalizes the longest root-prefixed prefix that fits, then appends only existing non-symlink components, preserving the documented ENAMETOOLONG fallback for a symlink beyond the host limit.
The current regression covers excess .. through the changed plain-path/AT_FDCWD route, while the real-directory-descriptor *at limitation remains explicitly listed as debt. macOS M1/M4 evidence exercises the actual long-path route, Windows evidence verifies unchanged behavior and the traversal regression, and every exact-head hosted check is terminal/successful (with the unrelated Linux/pipe-write jobs intentionally skipped).
I found no remaining blocker on this exact head.
AI-assisted: yes
|
Maintainer handoff for exact head |
|
Partial confirmation on macOS 15. Setup: Apple M4, macOS 15.7.9, Apple clang 17.0.0 (clang-1700.6.3.2), x86_64 Release under Rosetta,
So this PR's long-path fix can't be observed through AI-assisted: yes (Claude Code) |
|
Follow-up: I made the macOS 15 AI-assisted: yes (Claude Code) |
ligmaSec
left a comment
There was a problem hiding this comment.
Built and ran guest_kernel_sys on Linux with this head integrated. It passed. I traced the macOS path conversion to the root-relative operation used for long guest paths. The actual macOS PATH_MAX behavior remains unverified here.
AI-assisted: yes.
|
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.
|
What
On macOS, a guest path close to the 1024-byte guest limit failed with
ENAMETOOLONG. Its host form is the emulator root followed by the guest path, and macOS rejects host paths of 1024 bytes or more (#22270).The host working directory is the emulator root for the life of the process: guest
chdironly changesWorkingDirectory::current, and the only host change is inLoadExec, just before the process is replaced. So a path whose absolute host form would reachPATH_MAXis now passed to the host relative to the root. A guest path of at most 1023 bytes always fits that way. Shorter paths take the old route, and Windows is unchanged.In
core/libs/prx/libc/src/General.cpp:HostPathresolves such a path against an empty root.MatchNameslists.for an empty directory, so case-insensitive matching still applies on that route.SetWorkingDirectoryno longer callscanonical, whoserealpathresult must fit inPATH_MAX, on such a path. It canonicalizes the longest prefix that fits, then appends the remaining components after checking withsymlink_statusthat each exists and is not a symbolic link. A symbolic link past the host limit fails withENAMETOOLONG, as before. The..check against the root is unchanged.SetWorkingDirectoryandgetcwdrun theiris_directorycheck on the relative form.The debt entry for #22270 now lists the remaining limits: relative names used from a deep working directory, paths under an alias, descriptor-based
*atcalls, andfchdiron a long path. A separate M1 probe showedfchdirreturningENOTDIRfor a valid directory at the 1023-byte guest limit; recovering that descriptor path needs work outside this PR.Tested
-DCMAKE_OSX_ARCHITECTURES=x86_64, test targets and their libraries only:guest_kernel_sysandguest_kernel_sys_execve: fail onmain(Kernel sys check failed at line 1325 (guest errno 63),execve with a 1023 byte pathname did not reach the lookup), pass with this change.mainand with this change: the only difference isguest_kernel_sys.file_streams,guest_sce_net,guest_pollandguest_kernel_app_archive_mmapfail on both (fix(libc): fail a stream float scan of an empty hex prefix or a truncated infinity on macOS #21720, macOS: a listen backlog of 0 does not bound the pending accept queue, so guest_sce_net's connect-expiry case cannot pass #22443, fix(libkernel): report a reset stream socket polled for no event as hung up on macOS #20161, macOS: host code cannot inspect or catch guest exceptions, so four guest exception tests fail #21538).dc77871833onmain7281ddca51plus fix(libcurl): build the curl backend for the macOS target architecture #17425 and build(audio): link one SDL copy on macOS #11049 for the macOS build: Apple M1, macOS 26.5, x86_64 Release.libc,guest_kernel_sys_testsandguest_kernel_sys_execve_testsbuilt.guest_kernel_sys_execvepassed 3/3. With onlyCheckRawGetcwdPathLimitrun from the test binary, this change passed 3/3 andmainfailed 1/1 at line 1456 with guest errno 63. Temporary test edits were removed and the targets rebuilt.guest_kernel_sysnow stops at line 1190 with guest errno 13 in a directory rename permission check. With the new long-path check temporarily skipped, bothmainand this change stop at that same line. The test therefore cannot give a full-suite result on currentmain.fchdirprobe on a valid 1023-byte guest directory returnedENOTDIR(20). The probe was removed; the limit is recorded in the debt fragment.MatchNamesbuilds the same path as before (directory / entry->path().filename()equalsentry->path()).python3 tools/check_conventions.py --base origin/mainandgit diff --check origin/main...HEADpass on the rebased branch.python3 tools/debt_fold.py --checkfails on two untouched fragments in currentmain:docs-libkernel-pro-measured-1360.mdandfix-kernel-sys-title-workaround-bit-limit.md.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)