feat(libkernel_sys): implement statfs symlinkat and futimesat #9161

Merged
yabanana merged 17 commits from upstream-pr/9161 into main 2026-11-09 10:56:29 +00:00
yabanana commented 2026-10-21 14:04:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by yabanana on 2026-10-21T14:04:55Z.


What

Implement statfs, symlinkat and futimesat from the libkernel_sys discovery exports.

statfs resolves the guest path and shares the existing host-volume translation with _fstatfs, without opening the file for reading. Its 472-byte output uses the common GuestCopyOut_nid_no_patch checked-write boundary, returning EFAULT for inaccessible, read-only or partly inaccessible buffers and retaining host-write tracking. Archive-only paths still throw.

symlinkat reuses the existing symlink implementation with a descriptor-relative destination; futimesat reuses timestamp conversion and application. Absolute paths ignore the descriptor and AT_FDCWD uses the guest working directory. Invalid descriptors, non-directory descriptors, path limits, timestamp limits and null arguments are checked. FreeBSD's null-path EFAULT is retained for futimesat, rather than Linux's descriptor-only extension.

Export/NID presence was checked against the PS5 3.20 table. Signatures and semantics follow FreeBSD 11.4 symlink(2), statfs(2) and kern_utimesat. Existing mount identity, guest-root resolution, symlink-target and Windows path/privilege limitations are recorded in technical debt; no console or title-unblock claim.

#9008 is now merged. This branch includes its fstat-stub removal and retains the typed futimesat provider, so there is no remaining landing dependency.

The current-main integration keeps its checked guest-path copies and one shared symlink implementation. symlink/symlinkat have one definition each; statfs, futimesat and symlinkat have their typed declarations in libkernel_sys/include/Api.hpp. The statfs/timestamp helpers now use main's checked path snapshots as well.

Tested

9 November refresh at 38c80b83372f5a7d55958550712898a9a6184704 with main 67092e70b5211ed86d7a15e22cd10bca651901f5 merged. The merge retains both the raw-socket skip from upstream and the two privilege-only symlink skips. The relocation registrations and fixture follow upstream’s split suite.

14 focused Linux full-kernel executions pass. All 40 skip-checker tests pass, along with 9 macOS x86_64 relinker checks covering the split relocation suite and web packaging. All 39 web packaging tests, conventions, whitespace and the public-header audit (407 libraries and 33,818 exports) pass. Linux results use GCC 13.3 and a full Alpine 6.12.110 kernel under QEMU TCG with SMAP off, with fresh SHA256-verified binaries. macOS checks use macOS 27.3 and Apple clang 21 on ARM64 with an x86_64 target. New hosted checks are pending.

5 November CI fix: head 3adb34cdc76db8d17fd13fe98f6f4477ccee70ef cherry-picks maintainer commit acdbf77838 with its authorship. The macOS x86_64 hosted job timed out guest_none_relocations at20.07s. Upstream has reproduced the same budget issue and split its plain and SCE conversion groups into separate tests, each retaining TIMEOUT20; default all mode remains compatible with importing tests. Fresh local Release x86_64 relinker build passes none_relocations plus both guest halves, each repeated3times:9 executions, zero skips,10.92s total. macOS27.2/Appleclang21/ARM64 host running the x86_64 slice via Rosetta. Conventions and whitespace pass; syscall source and previously approved path tests are unchanged. New hosted CI is pending.

4 November update: head e0de57dc217c355b75b188f334caa2bf96df5b44, main b11c7bf84f integrated with published ancestry preserved. Removed stale parent-target refusal tests/wrapper; successful symlink creation now also checks a ../data target inside a child directory in the supported AT_FDCWD path. The error cases remain. statfs now uses shared GuestCopyOut_nid_no_patch instead of its private checked-write implementation, and debt reflects main's conditional parent-target refusal. The Windows privilege-only skip allowance remains necessary for the new symlink test; 37 skip-checker regressions pass.

14/14 focused full-kernel Linux executions pass (six common suites and eight syscall DLL/case combinations). Public-header ownership audit passes:406 libraries /28,350 exports. Conventions and whitespace pass. GCC13.3 cross on ARM64/Ubuntu24.04, Alpine6.12.110 kernel under QEMU8.2.2TCG cpu=max,smap=off,2vCPUs1536MiB, SHA256-verified fresh binaries. No fresh native Windows run; hosted checks must confirm this head. Earlier contributor reports remain tied to their original revisions. The first VM packaging attempts omitted main's new libSceNet/NetCtl dependencies; those loader failures are excluded and retained separately. The final run includes the actual built dependency closure.

29 October documentation update: the debt entry now explicitly records that Linux FIFO/socket paths report their containing filesystem and that console special-file behaviour remains unmeasured. Runtime source and tests are unchanged from d2f98f3910f054a76c793738be3d04d070a88c30.

benjaminmathias's native Windows report covers that source head integrated with main 2227f1366188cda5699dd20e2e756a18006a5d4b as tree c5708ba8076e89775a81e05416f97d67862a03dd: Windows 11 Pro 10.0.26300, Ryzen 7 5700X3D, WinLibs GCC 15.2.0 r7 UCRT Release. The integration has 48 passing executions and two explicit symlink-privilege skips; matched main has 24 passes. The actual JUnit passes this PR's skip checker and fails main's checker for exactly those two skips. Successful symlink creation/reparse assertions still require a privileged Windows run. This is attributed contributor evidence, not a local rerun or full-suite approval.

xdCloudy's firmware 13.60 wrapper analysis identifies statfs forwarding path/output to syscall 396; that supports the wrapper shape, not unmeasured console filesystem semantics. #12695 removed its duplicate statfs and depends on this provider.

28 October refresh: head d2f98f3910f054a76c793738be3d04d070a88c30, main c02d287bd0eb9fe0718940b2735811e97c2eb509 integrated by normal merge, preserving published ancestry. 14/14 focused Linux full-kernel executions pass on SHA256-verified binaries (GCC 13.3, Alpine 6.12.110, QEMU system 8.2.2 TCG, two vCPUs, 1536 MiB, cpu=max,smap=off). Tests/assertions were not changed. With SMAP enabled, the general kernel test hits a kernel fault at the new upstream context-restore IRET and times out; this CPU profile is not qualified by this refresh. No blanket native-hardware or zero-failure claim is made. Public-header ownership audit passes (368 libraries / 13,051 exports), as does full header compilation; conventions and whitespace checks pass; all 34 skip-checker tests pass. Fresh supported Windows runtime/full maintainer CI remains required. Earlier results below retain their original revisions.

27 October: maintainer @oneandonlydean merged main 74acfad65b into head d086e569050ed0d3a68d20444f8eae5a39cb10fd. That merge and authorship are retained. The reparse fixture and skip checker are byte-identical to c24c61778c; the exported symlinkat implementation/declaration is retained and the relocated sysKernelGet* stubs follow main. Current-head conventions, public-header audit and standalone/combined compilation pass (368 libraries, 12,368 exports), using native ARM64 Python and the x86-64 cross compiler. The historical runtime results below remain tied to their stated heads. Automatic relinker/ASan checks pass; full product Linux/Windows jobs in that automatic run are skipped. The maintainer announced full CI; its exact-head native result is not yet verified here.

26 October head c24c61778c688066de6ec0f4258c95c145133432, integrated main e796ed4e5e without rewriting published history. The public-header conflict retains both the typed futimesat declaration and main's typed get_authinfo declaration.

The Windows fixture now opens the link with FILE_FLAG_OPEN_REPARSE_POINT and reads FSCTL_GET_REPARSE_POINT. It requires IO_REPARSE_TAG_SYMLINK, the relative flag, bounded reparse data and the stored substitute target data. Linux retains read_symlink. Content reads, duplicate/absolute/descriptor-relative path assertions, both DLL modes, error and subprocess-refusal checks remain. The only privilege skip remains EPERM, with return code 77.

14/14 Linux full-kernel VM executions pass: four API/error selections in both library modes plus six common regressions. Linux x86-64 outputs built with GCC 13.3 cross compiler hosted on ARM64 / Ubuntu 24.04; copied binary SHA256s verified. Runtime: Alpine 6.12.110-0-virt, QEMU system 8.2.2 TCG cpu=max, two vCPUs, 1536 MiB. This is emulated CPU execution with real guest-kernel syscalls.

34 skip-checker tests pass after the main merge, including exact Windows creation privilege skips and rejection of mixed/prefixed unrelated reasons. Public-header audit passes (368 libraries, 12,228 exports); the affected libc/libkernel/libkernel_sys canonical headers compile together with repeated includes, and the complete targeted build passes. The all-library standalone and combined header compilation now also passes with native ARM64 Python and the existing GCC 13.3 x86-64 cross compiler. The earlier blocked emulated-Python run is retained separately; no ABI assertion was changed. Conventions and whitespace checks pass. The complete Windows fixture passes MinGW 13.2 UCRT syntax checks; this is not supported-toolchain native execution.

Native Windows CI 40249312977 identifies preceding head 16e92129ba: both creation cases abort on read_symlink: Function not implemented, while both error and both refusal cases pass. No JUnit artifact was available from that run. A private Wine 9 attempt cannot validate successful creation: Wine logs CreateSymbolicLinkW as a stub and opening the purported link fails with ERROR_FILE_NOT_FOUND. It is retained as an unsuccessful environment probe, not passing Windows evidence.

Please rerun both creation, error and refusal modes plus check_skips.py --job windows on the runner's WinLibs toolchain for this head. Full Linux/Windows CI requires maintainer dispatch. Prior contributor native results remain tied to their original heads. No native creation, console, macOS or title execution claim for this update.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4952905108 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9161). Originally posted by [yabanana](https://github.com/yabanana) on 2026-10-21T14:04:55Z. --- ### What Implement `statfs`, `symlinkat` and `futimesat` from the libkernel_sys discovery exports. `statfs` resolves the guest path and shares the existing host-volume translation with `_fstatfs`, without opening the file for reading. Its 472-byte output uses the common `GuestCopyOut_nid_no_patch` checked-write boundary, returning `EFAULT` for inaccessible, read-only or partly inaccessible buffers and retaining host-write tracking. Archive-only paths still throw. `symlinkat` reuses the existing symlink implementation with a descriptor-relative destination; `futimesat` reuses timestamp conversion and application. Absolute paths ignore the descriptor and `AT_FDCWD` uses the guest working directory. Invalid descriptors, non-directory descriptors, path limits, timestamp limits and null arguments are checked. FreeBSD's null-path `EFAULT` is retained for futimesat, rather than Linux's descriptor-only extension. Export/NID presence was checked against the [PS5 3.20 table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libkernel_sys.c). Signatures and semantics follow FreeBSD 11.4 [symlink(2)](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/lib/libc/sys/symlink.2), [statfs(2)](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/lib/libc/sys/statfs.2) and [kern_utimesat](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/kern/vfs_syscalls.c). Existing mount identity, guest-root resolution, symlink-target and Windows path/privilege limitations are recorded in technical debt; no console or title-unblock claim. #9008 is now merged. This branch includes its fstat-stub removal and retains the typed futimesat provider, so there is no remaining landing dependency. The current-main integration keeps its checked guest-path copies and one shared symlink implementation. symlink/symlinkat have one definition each; statfs, futimesat and symlinkat have their typed declarations in libkernel_sys/include/Api.hpp. The statfs/timestamp helpers now use main's checked path snapshots as well. ### Tested 9 November refresh at `38c80b83372f5a7d55958550712898a9a6184704` with `main` `67092e70b5211ed86d7a15e22cd10bca651901f5` merged. The merge retains both the raw-socket skip from upstream and the two privilege-only symlink skips. The relocation registrations and fixture follow upstream’s split suite. 14 focused Linux full-kernel executions pass. All 40 skip-checker tests pass, along with 9 macOS x86_64 relinker checks covering the split relocation suite and web packaging. All 39 web packaging tests, conventions, whitespace and the public-header audit (407 libraries and 33,818 exports) pass. Linux results use GCC 13.3 and a full Alpine 6.12.110 kernel under QEMU TCG with SMAP off, with fresh SHA256-verified binaries. macOS checks use macOS 27.3 and Apple clang 21 on ARM64 with an x86_64 target. New hosted checks are pending. 5 November CI fix: head `3adb34cdc76db8d17fd13fe98f6f4477ccee70ef` cherry-picks maintainer commit acdbf778382393de1cd889bcfa13f4cb3f7d6a08 with its authorship. The macOS x86_64 hosted job timed out guest_none_relocations at20.07s. Upstream has reproduced the same budget issue and split its plain and SCE conversion groups into separate tests, each retaining TIMEOUT20; default all mode remains compatible with importing tests. Fresh local Release x86_64 relinker build passes none_relocations plus both guest halves, each repeated3times:9 executions, zero skips,10.92s total. macOS27.2/Appleclang21/ARM64 host running the x86_64 slice via Rosetta. Conventions and whitespace pass; syscall source and previously approved path tests are unchanged. New hosted CI is pending. 4 November update: head `e0de57dc217c355b75b188f334caa2bf96df5b44`, main `b11c7bf84f` integrated with published ancestry preserved. Removed stale parent-target refusal tests/wrapper; successful symlink creation now also checks a `../data` target inside a child directory in the supported AT_FDCWD path. The error cases remain. `statfs` now uses shared GuestCopyOut_nid_no_patch instead of its private checked-write implementation, and debt reflects main's conditional parent-target refusal. The Windows privilege-only skip allowance remains necessary for the new symlink test; 37 skip-checker regressions pass. 14/14 focused full-kernel Linux executions pass (six common suites and eight syscall DLL/case combinations). Public-header ownership audit passes:406 libraries /28,350 exports. Conventions and whitespace pass. GCC13.3 cross on ARM64/Ubuntu24.04, Alpine6.12.110 kernel under QEMU8.2.2TCG cpu=max,smap=off,2vCPUs1536MiB, SHA256-verified fresh binaries. No fresh native Windows run; hosted checks must confirm this head. Earlier contributor reports remain tied to their original revisions. The first VM packaging attempts omitted main's new libSceNet/NetCtl dependencies; those loader failures are excluded and retained separately. The final run includes the actual built dependency closure. 29 October documentation update: the debt entry now explicitly records that Linux FIFO/socket paths report their containing filesystem and that console special-file behaviour remains unmeasured. Runtime source and tests are unchanged from `d2f98f3910f054a76c793738be3d04d070a88c30`. [benjaminmathias's native Windows report](https://github.com/boykopovar/AnyPS5/pull/9161#issuecomment-6468549993) covers that source head integrated with main `2227f1366188cda5699dd20e2e756a18006a5d4b` as tree `c5708ba8076e89775a81e05416f97d67862a03dd`: Windows 11 Pro 10.0.26300, Ryzen 7 5700X3D, WinLibs GCC 15.2.0 r7 UCRT Release. The integration has 48 passing executions and two explicit symlink-privilege skips; matched main has 24 passes. The actual JUnit passes this PR's skip checker and fails main's checker for exactly those two skips. Successful symlink creation/reparse assertions still require a privileged Windows run. This is attributed contributor evidence, not a local rerun or full-suite approval. [xdCloudy's firmware 13.60 wrapper analysis](https://github.com/boykopovar/AnyPS5/pull/9161#issuecomment-6486669061) identifies statfs forwarding path/output to syscall 396; that supports the wrapper shape, not unmeasured console filesystem semantics. #12695 removed its duplicate statfs and depends on this provider. 28 October refresh: head `d2f98f3910f054a76c793738be3d04d070a88c30`, main `c02d287bd0eb9fe0718940b2735811e97c2eb509` integrated by normal merge, preserving published ancestry. 14/14 focused Linux full-kernel executions pass on SHA256-verified binaries (GCC 13.3, Alpine 6.12.110, QEMU system 8.2.2 TCG, two vCPUs, 1536 MiB, **cpu=max,smap=off**). Tests/assertions were not changed. With SMAP enabled, the general kernel test hits a kernel fault at the new upstream context-restore IRET and times out; this CPU profile is not qualified by this refresh. No blanket native-hardware or zero-failure claim is made. Public-header ownership audit passes (368 libraries / 13,051 exports), as does full header compilation; conventions and whitespace checks pass; all 34 skip-checker tests pass. Fresh supported Windows runtime/full maintainer CI remains required. Earlier results below retain their original revisions. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> 27 October: maintainer @oneandonlydean merged main `74acfad65b` into head `d086e569050ed0d3a68d20444f8eae5a39cb10fd`. That merge and authorship are retained. The reparse fixture and skip checker are byte-identical to c24c61778c; the exported symlinkat implementation/declaration is retained and the relocated sysKernelGet* stubs follow main. Current-head conventions, public-header audit and standalone/combined compilation pass (368 libraries, 12,368 exports), using native ARM64 Python and the x86-64 cross compiler. The historical runtime results below remain tied to their stated heads. Automatic relinker/ASan checks pass; full product Linux/Windows jobs in that automatic run are skipped. The maintainer announced full CI; its exact-head native result is not yet verified here. 26 October head `c24c61778c688066de6ec0f4258c95c145133432`, integrated main `e796ed4e5e` without rewriting published history. The public-header conflict retains both the typed futimesat declaration and main's typed get_authinfo declaration. The Windows fixture now opens the link with FILE_FLAG_OPEN_REPARSE_POINT and reads FSCTL_GET_REPARSE_POINT. It requires IO_REPARSE_TAG_SYMLINK, the relative flag, bounded reparse data and the stored substitute target `data`. Linux retains read_symlink. Content reads, duplicate/absolute/descriptor-relative path assertions, both DLL modes, error and subprocess-refusal checks remain. The only privilege skip remains EPERM, with return code 77. 14/14 Linux full-kernel VM executions pass: four API/error selections in both library modes plus six common regressions. Linux x86-64 outputs built with GCC 13.3 cross compiler hosted on ARM64 / Ubuntu 24.04; copied binary SHA256s verified. Runtime: Alpine 6.12.110-0-virt, QEMU system 8.2.2 TCG cpu=max, two vCPUs, 1536 MiB. This is emulated CPU execution with real guest-kernel syscalls. 34 skip-checker tests pass after the main merge, including exact Windows creation privilege skips and rejection of mixed/prefixed unrelated reasons. Public-header audit passes (368 libraries, 12,228 exports); the affected libc/libkernel/libkernel_sys canonical headers compile together with repeated includes, and the complete targeted build passes. The all-library standalone and combined header compilation now also passes with native ARM64 Python and the existing GCC 13.3 x86-64 cross compiler. The earlier blocked emulated-Python run is retained separately; no ABI assertion was changed. Conventions and whitespace checks pass. The complete Windows fixture passes MinGW 13.2 UCRT syntax checks; this is not supported-toolchain native execution. [Native Windows CI 40249312977](https://github.com/boykopovar/AnyPS5/actions/runs/40249312977/job/121337532539) identifies preceding head `16e92129ba`: both creation cases abort on `read_symlink: Function not implemented`, while both error and both refusal cases pass. No JUnit artifact was available from that run. A private Wine 9 attempt cannot validate successful creation: Wine logs CreateSymbolicLinkW as a stub and opening the purported link fails with ERROR_FILE_NOT_FOUND. It is retained as an unsuccessful environment probe, not passing Windows evidence. Please rerun both creation, error and refusal modes plus check_skips.py --job windows on the runner's WinLibs toolchain for this head. Full Linux/Windows CI requires maintainer dispatch. Prior contributor native results remain tied to their original heads. No native creation, console, macOS or title execution claim for this update. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
CnRJay commented 2026-11-01 20:04:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T20:04:54Z.

Review: COMMENTED


Scope: the diff also edits tools/check_skips.py and adds tools/tests/test_check_skips.py, which has nothing to do with the three syscalls. Is that needed for the new GuestKernelSysPathRefusal test? If so say why; otherwise it belongs in its own PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729973347 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9161#pullrequestreview-5729973347). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T20:04:54Z. **Review:** COMMENTED --- Scope: the diff also edits `tools/check_skips.py` and adds `tools/tests/test_check_skips.py`, which has nothing to do with the three syscalls. Is that needed for the new `GuestKernelSysPathRefusal` test? If so say why; otherwise it belongs in its own PR.
BunnyFl commented 2026-11-03 03:54:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-03T03:54:05Z.

Review: CHANGES_REQUESTED


Windows 11, WinLibs GCC, Release, BUILD_TESTING=ON, head 9f173116fe merged onto current main f6232fcfda (clean merge):

tests result
guest_kernel_sys_paths_statfs, _futimesat, _symlinkat_errors (each plus _patched), check_skips, check_skips_ctest pass
guest_kernel_sys_paths_symlinkat and _patched skip (77), the Windows privilege case
guest_kernel_sys_paths_symlinkat_refused_unpatched and _patched fail: "Expected the symlink parent-target refusal; result=0"

Blocking: the refusal tests are stale against current main. Dom3005's 69a7bd2c19 ("create symlink targets with parent-directory components", 2026-10-24) changed main's symlink. A .. target is now created whenever the host would follow it to the guest path it names. Only otherwise does it refuse, and with a different message: "symlink: a parent-directory target the host would not follow to the guest path it names" (core/libs/prx/libkernel_sys/Export.cpp:948 on main).

This fixture still calls symlinkat("../data", base, "refused") (core/libs/tests/GuestKernelSysPaths.cpp:229-231) and requires the old "parent-directory targets not implemented" text (core/libs/tests/GuestKernelSysPathRefusal.cmake:9-10). That call is now allowed and returns 0. The fix belongs in the test: either drop the refusal case, or pick a target HostFollowsGuestTarget rejects and match the new message. The positive case could then assert that a ../data link is created where the privilege allows it.

Firmware 13.42: system/common/lib/libkernel_sys.sprx (sha256 3d361753f6c472cd5442bf92652b4a1dee04051297a0155fe197ede0c2002d4a) supports the FreeBSD-syscall model. This is disassembly only, not measured on a console. statfs (0x1a90), futimesat (0x2190) and symlinkat (0x2270) are bare wrappers: mov $0x18c,%rax, $0x1ee and $0x1f6 respectively, then syscall, and on carry a jump to the errno setter at 0xd4. Those are FreeBSD's syscall numbers 396, 494 and 502 for the same calls, matching what xdCloudy reported for 13.60's statfs.

Non-blocking:

  • @CnRJay's scope question has an answer in this thread. The Windows job's check_skips.py audit rejected the new privilege skip (@oneandonlydean, 2026-10-24), so the allowance belongs here. It does conflict with #15095, which also extends check_skips.py: merging both onto main conflicts in tools/tests/test_check_skips.py, so whichever lands second needs a resolution.
  • CopyStatfs (core/libs/prx/libkernel/File/src/Stdio.cpp) has its own checked write (VirtualQuery+WriteProcessMemory, process_vm_writev, mach_vm_write). main now has GuestCopyOut_nid_no_patch (core/libs/prx/libc/include/General.hpp:36), which could replace it.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5747068958 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9161#pullrequestreview-5747068958). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-03T03:54:05Z. **Review:** CHANGES_REQUESTED --- Windows 11, WinLibs GCC, Release, `BUILD_TESTING=ON`, head `9f173116fe` merged onto current `main` `f6232fcfda` (clean merge): | tests | result | |---|---| | `guest_kernel_sys_paths_statfs`, `_futimesat`, `_symlinkat_errors` (each plus `_patched`), `check_skips`, `check_skips_ctest` | pass | | `guest_kernel_sys_paths_symlinkat` and `_patched` | skip (77), the Windows privilege case | | `guest_kernel_sys_paths_symlinkat_refused_unpatched` and `_patched` | **fail**: "Expected the symlink parent-target refusal; result=0" | **Blocking: the refusal tests are stale against current `main`.** Dom3005's 69a7bd2c19 ("create symlink targets with parent-directory components", 2026-10-24) changed `main`'s symlink. A `..` target is now created whenever the host would follow it to the guest path it names. Only otherwise does it refuse, and with a different message: "symlink: a parent-directory target the host would not follow to the guest path it names" (`core/libs/prx/libkernel_sys/Export.cpp:948` on `main`). This fixture still calls `symlinkat("../data", base, "refused")` (`core/libs/tests/GuestKernelSysPaths.cpp:229-231`) and requires the old "parent-directory targets not implemented" text (`core/libs/tests/GuestKernelSysPathRefusal.cmake:9-10`). That call is now allowed and returns 0. The fix belongs in the test: either drop the refusal case, or pick a target `HostFollowsGuestTarget` rejects and match the new message. The positive case could then assert that a `../data` link is created where the privilege allows it. **Firmware 13.42:** `system/common/lib/libkernel_sys.sprx` (sha256 `3d361753f6c472cd5442bf92652b4a1dee04051297a0155fe197ede0c2002d4a`) supports the FreeBSD-syscall model. This is disassembly only, not measured on a console. `statfs` (`0x1a90`), `futimesat` (`0x2190`) and `symlinkat` (`0x2270`) are bare wrappers: `mov $0x18c,%rax`, `$0x1ee` and `$0x1f6` respectively, then `syscall`, and on carry a jump to the errno setter at `0xd4`. Those are FreeBSD's syscall numbers 396, 494 and 502 for the same calls, matching what xdCloudy reported for 13.60's `statfs`. **Non-blocking:** - @CnRJay's scope question has an answer in this thread. The Windows job's `check_skips.py` audit rejected the new privilege skip (@oneandonlydean, 2026-10-24), so the allowance belongs here. It does conflict with #15095, which also extends `check_skips.py`: merging both onto `main` conflicts in `tools/tests/test_check_skips.py`, so whichever lands second needs a resolution. - `CopyStatfs` (`core/libs/prx/libkernel/File/src/Stdio.cpp`) has its own checked write (`VirtualQuery`+`WriteProcessMemory`, `process_vm_writev`, `mach_vm_write`). `main` now has `GuestCopyOut_nid_no_patch` (`core/libs/prx/libc/include/General.hpp:36`), which could replace it.
BunnyFl commented 2026-11-04 13:16:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T13:16:53Z.

Review: APPROVED


@yabanana thanks, my blocking point is resolved at e0de57dc21. The stale refusal registrations (GuestKernelSysPathRefusal.cmake and the symlinkat_refused case) are gone. The positive case now creates ../data from a child directory through AT_FDCWD and reads the file back, which is what main's conditional HostFollowsGuestTarget path allows.

What I ran: head e0de57dc21 (it fast-forwards onto main b11c7bf84f), Windows 11, WinLibs GCC, Release, BUILD_TESTING=ON:

  • 10 tests: guest_kernel_sys_paths_statfs, _symlinkat_errors and _futimesat (each plus _patched), check_skips and check_skips_ctest pass;
  • guest_kernel_sys_paths_symlinkat and _patched skip (77) for the missing symlink privilege on this machine. So the new ../data case didn't run here, and I'm relying on your Linux run for it;
  • the two cases that failed in my last review no longer exist, and nothing fails;
  • tools/check_conventions.py --base upstream/main on the head: all checks passed;
  • tools/pr_overlap.py --branch: no shared exports. None of the 12 PRs it couldn't compare adds statfs, symlinkat or futimesat lines.

Approving.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5768973364 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9161#pullrequestreview-5768973364). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-04T13:16:53Z. **Review:** APPROVED --- @yabanana thanks, my blocking point is resolved at `e0de57dc21`. The stale refusal registrations (`GuestKernelSysPathRefusal.cmake` and the `symlinkat_refused` case) are gone. The positive case now creates `../data` from a child directory through `AT_FDCWD` and reads the file back, which is what `main`'s conditional `HostFollowsGuestTarget` path allows. **What I ran:** head `e0de57dc21` (it fast-forwards onto `main` `b11c7bf84f`), Windows 11, WinLibs GCC, Release, `BUILD_TESTING=ON`: - 10 tests: `guest_kernel_sys_paths_statfs`, `_symlinkat_errors` and `_futimesat` (each plus `_patched`), `check_skips` and `check_skips_ctest` pass; - `guest_kernel_sys_paths_symlinkat` and `_patched` skip (77) for the missing symlink privilege on this machine. So the new `../data` case didn't run here, and I'm relying on your Linux run for it; - the two cases that failed in my last review no longer exist, and nothing fails; - `tools/check_conventions.py --base upstream/main` on the head: all checks passed; - `tools/pr_overlap.py --branch`: no shared exports. None of the 12 PRs it couldn't compare adds `statfs`, `symlinkat` or `futimesat` lines. Approving.
BunnyFl commented 2026-11-05 14:16:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-05T14:16:28Z.

Review: APPROVED


@yabanana re-checked at 3adb34cdc7. The only new commit is the relinker test split, and git range-diff shows it is the same patch as acdbf77838 on main; the PR's own changes are unchanged since my approval of e0de57dc21. @oneandonlydean, that approval had already replaced my change request when you asked on the 4th; sorry I didn't say so on the thread.

On 3adb34cdc7 merged onto main 78e4248fea (Windows 11, WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON):

  • 12 tests: guest_kernel_sys_paths_statfs, _symlinkat_errors and _futimesat (each plus _patched), check_skips, check_skips_ctest, guest_none_relocations and guest_none_relocations_sce pass; guest_kernel_sys_paths_symlinkat and _patched skip (77) for the missing symlink privilege on this machine, as before.
  • With main's tools/check_skips.py, check_skips fails and the rest pass. That control covers only the skip allowance, not the kernel calls.
  • check_conventions.py passes. pr_overlap.py --branch finds no shared exports; #11034, #14902, #15037 and #15095 share lines, and 36 PRs that conflict with main couldn't be compared.

Approving again at 3adb34cdc7.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5786320957 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9161#pullrequestreview-5786320957). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-05T14:16:28Z. **Review:** APPROVED --- @yabanana re-checked at `3adb34cdc7`. The only new commit is the relinker test split, and `git range-diff` shows it is the same patch as `acdbf77838` on `main`; the PR's own changes are unchanged since my [approval](https://github.com/boykopovar/AnyPS5/pull/9161#pullrequestreview-5768973364) of `e0de57dc21`. @oneandonlydean, that approval had already replaced my change request when you asked on the 4th; sorry I didn't say so on the thread. On `3adb34cdc7` merged onto `main` `78e4248fea` (Windows 11, WinLibs GCC 15.2.0, Release, `BUILD_TESTING=ON`): - 12 tests: `guest_kernel_sys_paths_statfs`, `_symlinkat_errors` and `_futimesat` (each plus `_patched`), `check_skips`, `check_skips_ctest`, `guest_none_relocations` and `guest_none_relocations_sce` pass; `guest_kernel_sys_paths_symlinkat` and `_patched` skip (77) for the missing symlink privilege on this machine, as before. - With `main`'s `tools/check_skips.py`, `check_skips` fails and the rest pass. That control covers only the skip allowance, not the kernel calls. - `check_conventions.py` passes. `pr_overlap.py --branch` finds no shared exports; #11034, #14902, #15037 and #15095 share lines, and 36 PRs that conflict with `main` couldn't be compared. Approving again at `3adb34cdc7`. AI-assisted: yes (Claude Code)
BunnyFl commented 2026-11-09 22:39:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-09T22:39:09Z.

Review: COMMENTED


@yabanana re-checked at 38c80b8337 as asked. The merge is clean against current main e7c3bfd130, the eight tests and the tool test pass here, each export's own mutation control fails as it should, and nothing overlaps. One finding below, on the descriptor-relative futimesat path, reproduced here as a crash; everything else I approved at 3adb34cdc7 is unchanged.

What moved since that approval. 38c80b8337 is a merge commit, its parents are 3adb34cdc7 and main 67092e70b5, and it carries no other commit. Comparing the branch's own added and removed lines at the two heads, they are identical in seven of its files. Two differ, both correctly:

  • tools/check_skips.py keeps main's raw-socket pattern in the device_limitations call at tools/check_skips.py:98 and its sentence, and re-applies the branch's own filter in the same line. The filter itself is tools/check_skips.py:29.
  • docs/dev/debt/libkernel_sys.md has the same two entries, with one blank line added above them.

The two relinker files left the branch: main registers that test per mode and system at core/relinker/CMakeLists.txt:656, the merge took main's version, and the branch's two-halves split is gone. main's split is the finer of the two, and I have no objection to the branch taking it.

Finding (P2, reproduced below): the descriptor-relative futimesat dereferences the guest times array at core/libs/prx/libkernel/File/src/Stdio.cpp:2089 and hands the same pointer to NativeUtimes at core/libs/prx/libkernel/File/src/Stdio.cpp:2098, with no copy-in on that path.

Its three neighbours call CopyInTimes first: core/libs/prx/libkernel/File/src/Stdio.cpp:2066, core/libs/prx/libkernel/File/src/Stdio.cpp:2080 and core/libs/prx/libkernel/File/src/Stdio.cpp:2104, each returning a failure for a pointer it cannot read rather than reading it. The function at core/libs/prx/libkernel/File/src/Stdio.cpp:2088 forwards to utimes_nid_postfix when the descriptor is -100 or the path is absolute. That path copies in at core/libs/prx/libkernel/File/src/Stdio.cpp:2080. Only the descriptor-relative branch is in question, and I did not run the forwarding case against a bad pointer.

The failing case, added as one more case to your own futimesat section right after core/libs/tests/GuestKernelSysPaths.cpp:164: commit two pages, make the second one unreadable the way your statfs case does at core/libs/tests/GuestKernelSysPaths.cpp:131, and call futimesat(base, "data", <start of that second page>), expecting -1 and error 14. Both futimesat tests then end this way, in two separate runs at 38c80b8337 merged onto main e7c3bfd130 (0 of 2 passed, nothing Not Run):

1/2 Test #634: guest_kernel_sys_paths_futimesat ...........***Exception: SegFault  0.21 sec
2/2 Test #635: guest_kernel_sys_paths_futimesat_patched ...***Exception: SegFault  0.11 sec

Your output-buffer cases already ask for -1 and error 14 in that situation, first with a read-only page at core/libs/tests/GuestKernelSysPaths.cpp:128 and then with a destination straddling an unreadable page at core/libs/tests/GuestKernelSysPaths.cpp:136. I read those two as the answer you want for an unreadable input as well. Copying the array in before the check at core/libs/prx/libkernel/File/src/Stdio.cpp:2089, the way the three lines above do it, would be enough, and it would also make the two spellings of the same call agree for one pointer. If you would rather keep the direct read, a line in docs/dev/debt/libkernel_sys.md would record it: I have not read firmware 13.42's futimesat, so I cannot say what the console does with an unreadable times.

Scope question from @CnRJay (1 Nov). The tools/check_skips.py change is for this pull request's own tests, and this run shows it. On a Windows host without the symbolic-link privilege, guest_kernel_sys_paths_symlinkat and guest_kernel_sys_paths_symlinkat_patched print the reason at core/libs/tests/GuestKernelSysPaths.cpp:172 and exit 77 at core/libs/tests/GuestKernelSysPaths.cpp:234, which check_skips.py reports as an unexpected skip without the new filter; the filter at tools/check_skips.py:29 matches that exact string for exactly those two test names. That places it with these tests rather than in a pull request of its own.

Runs. Windows 11 Pro 10.0.26300, AMD Ryzen 7 5800X3D, WinLibs GCC, Release, BUILD_TESTING=ON, head 38c80b8337 merged into main e7c3bfd130 (clean merge), with guest_kernel_sys_paths_tests, libkernel_sys and libkernel rebuilt at that tree:

  • 8 of 8, none Not Run: guest_kernel_sys_paths_statfs, guest_kernel_sys_paths_statfs_patched, guest_kernel_sys_paths_symlinkat_errors, guest_kernel_sys_paths_symlinkat_errors_patched, guest_kernel_sys_paths_futimesat and guest_kernel_sys_paths_futimesat_patched pass; guest_kernel_sys_paths_symlinkat and guest_kernel_sys_paths_symlinkat_patched are Skipped for the privilege reason above. No symbolic-link creation ran on this host: both of those tests stop at core/libs/tests/GuestKernelSysPaths.cpp:172, ahead of the reparse-point assertions and the -100, absolute-path and existing-link cases.
  • py -3 -I tools/tests/test_check_skips.py: 40 tests, OK.
  • Mutation controls, one per export, each with guest_kernel_sys_paths_tests relinked at the mutated tree. statfs_nid_postfix returning 0 instead of calling PosixStatfs_nid_no_patch: both statfs tests fail. futimesat_nid_postfix returning 0: both futimesat tests fail. symlinkat_nid_postfix returning 0: all four symlinkat tests fail, the creation pair included, since with a reported success the skip branch at core/libs/tests/GuestKernelSysPaths.cpp:172 is not reached.
  • A file-level negative control is not possible here: the pull request also retypes the three declarations in core/libs/prx/libkernel_sys/include/Api.hpp, so main's implementations do not compile against this test. The mutations above stand in for it.
  • tools/pr_overlap.py --branch ov-9161 --jobs 8 on the merged head: no overlap with open pull requests, exit 0 — no shared file, export, line or new file.
  • Not run here: Linux, macOS, any sanitizer build, symbolic-link creation (skipped), and no title.

I have not reproduced @JJenkx's Windows remove_all timeout, and this host cannot: both symlinkat tests stop at core/libs/tests/GuestKernelSysPaths.cpp:172 before creating a link. Their finding and #17894 rest on their own runs, not on anything I checked.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5833846562 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9161#pullrequestreview-5833846562). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-09T22:39:09Z. **Review:** COMMENTED --- @yabanana re-checked at `38c80b8337` as asked. The merge is clean against current `main` `e7c3bfd130`, the eight tests and the tool test pass here, each export's own mutation control fails as it should, and nothing overlaps. One finding below, on the descriptor-relative `futimesat` path, reproduced here as a crash; everything else I approved at `3adb34cdc7` is unchanged. **What moved since that approval.** [`38c80b8337`](https://github.com/boykopovar/AnyPS5/pull/9161/commits/38c80b83372f5a7d55958550712898a9a6184704) is a merge commit, its parents are `3adb34cdc7` and `main` `67092e70b5`, and it carries no other commit. Comparing the branch's own added and removed lines at the two heads, they are identical in seven of its files. Two differ, both correctly: - `tools/check_skips.py` keeps `main`'s raw-socket pattern in the `device_limitations` call at `tools/check_skips.py:98` and its sentence, and re-applies the branch's own filter in the same line. The filter itself is `tools/check_skips.py:29`. - `docs/dev/debt/libkernel_sys.md` has the same two entries, with one blank line added above them. The two relinker files left the branch: `main` registers that test per mode and system at `core/relinker/CMakeLists.txt:656`, the merge took `main`'s version, and the branch's two-halves split is gone. `main`'s split is the finer of the two, and I have no objection to the branch taking it. **Finding (P2, reproduced below): the descriptor-relative `futimesat` dereferences the guest `times` array at `core/libs/prx/libkernel/File/src/Stdio.cpp:2089` and hands the same pointer to `NativeUtimes` at `core/libs/prx/libkernel/File/src/Stdio.cpp:2098`, with no copy-in on that path.** Its three neighbours call `CopyInTimes` first: `core/libs/prx/libkernel/File/src/Stdio.cpp:2066`, `core/libs/prx/libkernel/File/src/Stdio.cpp:2080` and `core/libs/prx/libkernel/File/src/Stdio.cpp:2104`, each returning a failure for a pointer it cannot read rather than reading it. The function at `core/libs/prx/libkernel/File/src/Stdio.cpp:2088` forwards to `utimes_nid_postfix` when the descriptor is -100 or the path is absolute. That path copies in at `core/libs/prx/libkernel/File/src/Stdio.cpp:2080`. Only the descriptor-relative branch is in question, and I did not run the forwarding case against a bad pointer. The failing case, added as one more case to your own futimesat section right after `core/libs/tests/GuestKernelSysPaths.cpp:164`: commit two pages, make the second one unreadable the way your statfs case does at `core/libs/tests/GuestKernelSysPaths.cpp:131`, and call `futimesat(base, "data", <start of that second page>)`, expecting -1 and error 14. Both futimesat tests then end this way, in two separate runs at `38c80b8337` merged onto `main` `e7c3bfd130` (0 of 2 passed, nothing Not Run): ``` 1/2 Test #634: guest_kernel_sys_paths_futimesat ...........***Exception: SegFault 0.21 sec 2/2 Test #635: guest_kernel_sys_paths_futimesat_patched ...***Exception: SegFault 0.11 sec ``` Your output-buffer cases already ask for -1 and error 14 in that situation, first with a read-only page at `core/libs/tests/GuestKernelSysPaths.cpp:128` and then with a destination straddling an unreadable page at `core/libs/tests/GuestKernelSysPaths.cpp:136`. I read those two as the answer you want for an unreadable input as well. Copying the array in before the check at `core/libs/prx/libkernel/File/src/Stdio.cpp:2089`, the way the three lines above do it, would be enough, and it would also make the two spellings of the same call agree for one pointer. If you would rather keep the direct read, a line in `docs/dev/debt/libkernel_sys.md` would record it: I have not read firmware 13.42's `futimesat`, so I cannot say what the console does with an unreadable `times`. **Scope question from @CnRJay (1 Nov).** The `tools/check_skips.py` change is for this pull request's own tests, and this run shows it. On a Windows host without the symbolic-link privilege, `guest_kernel_sys_paths_symlinkat` and `guest_kernel_sys_paths_symlinkat_patched` print the reason at `core/libs/tests/GuestKernelSysPaths.cpp:172` and exit 77 at `core/libs/tests/GuestKernelSysPaths.cpp:234`, which `check_skips.py` reports as an unexpected skip without the new filter; the filter at `tools/check_skips.py:29` matches that exact string for exactly those two test names. That places it with these tests rather than in a pull request of its own. **Runs.** Windows 11 Pro 10.0.26300, AMD Ryzen 7 5800X3D, WinLibs GCC, Release, `BUILD_TESTING=ON`, head `38c80b8337` merged into `main` `e7c3bfd130` (clean merge), with `guest_kernel_sys_paths_tests`, `libkernel_sys` and `libkernel` rebuilt at that tree: - **8 of 8, none Not Run:** `guest_kernel_sys_paths_statfs`, `guest_kernel_sys_paths_statfs_patched`, `guest_kernel_sys_paths_symlinkat_errors`, `guest_kernel_sys_paths_symlinkat_errors_patched`, `guest_kernel_sys_paths_futimesat` and `guest_kernel_sys_paths_futimesat_patched` pass; `guest_kernel_sys_paths_symlinkat` and `guest_kernel_sys_paths_symlinkat_patched` are **Skipped** for the privilege reason above. **No symbolic-link creation ran on this host:** both of those tests stop at `core/libs/tests/GuestKernelSysPaths.cpp:172`, ahead of the reparse-point assertions and the `-100`, absolute-path and existing-link cases. - `py -3 -I tools/tests/test_check_skips.py`: 40 tests, OK. - **Mutation controls**, one per export, each with `guest_kernel_sys_paths_tests` relinked at the mutated tree. `statfs_nid_postfix` returning 0 instead of calling `PosixStatfs_nid_no_patch`: both statfs tests fail. `futimesat_nid_postfix` returning 0: both futimesat tests fail. `symlinkat_nid_postfix` returning 0: all four symlinkat tests fail, the creation pair included, since with a reported success the skip branch at `core/libs/tests/GuestKernelSysPaths.cpp:172` is not reached. - A file-level negative control is not possible here: the pull request also retypes the three declarations in `core/libs/prx/libkernel_sys/include/Api.hpp`, so `main`'s implementations do not compile against this test. The mutations above stand in for it. - `tools/pr_overlap.py --branch ov-9161 --jobs 8` on the merged head: **no overlap with open pull requests**, exit 0 — no shared file, export, line or new file. - Not run here: Linux, macOS, any sanitizer build, symbolic-link creation (skipped), and no title. I have not reproduced @JJenkx's Windows `remove_all` timeout, and this host cannot: both symlinkat tests stop at `core/libs/tests/GuestKernelSysPaths.cpp:172` before creating a link. Their finding and #17894 rest on their own runs, not on anything I checked. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!9161
No description provided.