fix(libkernel_sys): build and check fchdir search permission on macOS #6667
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6667"
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 DavidSamir on 2026-10-16T03:23:13Z.
What
libkernel_sys does not build on macOS since
unlinkat(55ddffe26): itsrmdirandunlinkpaths call::rmdirand::unlinkoutside the Windows branch, but<unistd.h>,<fcntl.h>and<cerrno>are included only under__linux__:They are now included on every host but Windows, the split the code that uses them already makes.
The same
__linux__guard keptfchdir's search-permission check (0e4d94ce3) off macOS, so a guest could change into a directory it may not search, where FreeBSD'schange_dirfails withEACCESand keeps the working directory.faccessat(fd, ".", X_OK, AT_EACCESS)is POSIX and behaves the same on macOS, so the check now runs on every host but Windows, and so does the test case that covers it. Thefchdirdebt entry still said the check was not modelled; it now says where it runs.Four commits: the header fix, the
fchdircheck, its test, the debt entry.Tested
macOS 26.7.1, Apple M2, AppleClang 21.0.0, x86-64 build under Rosetta, Release.
maindoes not build libc and libkernel on macOS for other reasons as well (#4627, #4630, #6124 and mugurc's macOS branches address them), so the tests ran in a local tree ofmaince991f1ecwith those merged. On macOS,fchdiralso needs the directory-descriptor path lookup throughF_GETPATHthat mugurc'sfeat/libkernel-files-macosbranch adds; onmainalone the lookup reads/proc/self/fd, which macOS does not have.main'sExport.cpp: libkernel_sys fails to compile with the errors above.guest_kernel_syspasses 3 runs of 3.fchdirchange:guest_kernel_sysaborts (3 of 3), asfchdirinto the directory without search permission succeeds.guest_kernel_syspasses 5 runs of 5.tools/check_conventions.py --base origin/mainandgit diff --checkpass.Windows 11 (WinLibs GCC 15.2.0 r7, UCRT, Release) and Ubuntu 24.04 under WSL2 (GCC 13.3.0, Release), head
e44e828f6merged ontomain5d9dcc42d:guest_kernel_syspass 3 runs of 3 with the change, and 3 runs of 3 withlibkernel_sys/Export.cppas onmainand the tests kept. It passes either way there, as the change alters only the macOS path; on Linux the included headers and the check are unchanged, and on Windows none of the changed lines are compiled.Overlap: #6222 changes the same include guard inside its macOS work. #6044 moves
GuestKernelSys.cpp, and #6447 edits another entry oflibkernel_sys.md; whichever lands second rebases.Checklist
main; no other open PR implements the same functions (see Overlap above)NotImplemented_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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T03:26:22Z.
Review: APPROVED
The macOS-only header guard change matches the POSIX calls used outside the Windows branch, and the
fchdirpermission check and test are guarded consistently. The reported macOS test results cover the change; the unrelated base-branch macOS build failures are called out. I found no remaining code blocker. The overlap with #6222 is documented and appears to require only a merge resolution, not a dependency.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T03:38:01Z.
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.
core/libs/prx/libkernel_sys/Export.cppcore/libs/tests/GuestKernelSys.cppcore/libs/tests/GuestKernelSys.cppcore/libs/prx/libkernel_sys/Export.cppcore/libs/prx/libkernel_sys/Export.cppdocs/dev/debt/libkernel_sys.mdImported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-16T07:33:39Z.
Windows and Linux results for
e44e828f61, merged ontomain5d9dcc42d2:main, new tests keptguest_kernel_sys3/3guest_kernel_sys3/3Reverted for the middle column:
libkernel_sys/Export.cpp. On both hosts the test passes either way, as expected for a change that only alters the macOS path. This shows the edited shared code still builds and passes on Windows and Linux.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T08:19:46Z.
Checked the diff against the description: the
__linux__→!_WIN32guard change in the includes, thefchdirfaccessat(fd, ".", X_OK, AT_EACCESS)check and its test case, and the updatedfchdirdebt entry. Linux behaviour is unchanged and the Windows path isn't compiled. macOS results are from your M2 runs and the third-party macOS runs.