fix(libkernel): validate clock_settime before EPERM #17551

Closed
AasishDairelSahayaGrinspan wants to merge 1 commit from upstream-pr/17551 into main
AasishDairelSahayaGrinspan commented 2026-11-08 21:52:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AasishDairelSahayaGrinspan on 2026-11-08T21:52:58Z.


What

Validate clock_settime arguments like FreeBSD 11.4 before returning EPERM for a valid CLOCK_REALTIME request. This preserves the host clock and models the title's jailed environment rather than throwing for valid requests.

Tested

macOS 26, AppleClang: python3 tools/check_conventions.py --base origin/main passed. Build/test attempted via cmake -S . -B build-clock-settime -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON and cmake --build build-clock-settime --target guest_freebsd_clocks_tests -j 4; build blocked by existing unrelated compile errors in core/libs/prx/libc/src/RunReport.cpp (std::thread unavailable in this compiler configuration). The new test adds valid realtime → EPERM and verifies invalid clock/field inputs → EINVAL; the existing validation cases remain. No PS5 hardware test.

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:5215469470 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17551). Originally posted by [AasishDairelSahayaGrinspan](https://github.com/AasishDairelSahayaGrinspan) on 2026-11-08T21:52:58Z. --- ### What Validate `clock_settime` arguments like FreeBSD 11.4 before returning `EPERM` for a valid `CLOCK_REALTIME` request. This preserves the host clock and models the title's jailed environment rather than throwing for valid requests. ### Tested <!-- 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. --> macOS 26, AppleClang: `python3 tools/check_conventions.py --base origin/main` passed. Build/test attempted via `cmake -S . -B build-clock-settime -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON` and `cmake --build build-clock-settime --target guest_freebsd_clocks_tests -j 4`; build blocked by existing unrelated compile errors in `core/libs/prx/libc/src/RunReport.cpp` (`std::thread` unavailable in this compiler configuration). The new test adds valid realtime → `EPERM` and verifies invalid clock/field inputs → `EINVAL`; the existing validation cases remain. No PS5 hardware test. ### 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
gabichuuuuu commented 2026-11-09 08:51:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-09T08:51:59Z.

Review: COMMENTED


Windows run of head 4b61ec368d, merged onto main 286b14d2f7 in one tree with 47 other small open PRs that touch different files. Setup: Windows 11, WinLibs GCC 15.2 r7 (x86_64-ucrt-posix-seh, the CI toolchain), Release, BUILD_TESTING=ON.

  • guest_freebsd_clocks with --repeat until-fail:5: 5 / 5 pass.
  • Negative control, with main's Time.cpp and this PR's test: 5 / 5 runs fail.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5823547660 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17551#pullrequestreview-5823547660). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-09T08:51:59Z. **Review:** COMMENTED --- Windows run of head `4b61ec368d`, merged onto `main` `286b14d2f7` in one tree with 47 other small open PRs that touch different files. Setup: Windows 11, WinLibs GCC 15.2 r7 (`x86_64-ucrt-posix-seh`, the CI toolchain), Release, `BUILD_TESTING=ON`. - `guest_freebsd_clocks` with `--repeat until-fail:5`: 5 / 5 pass. - **Negative control,** with `main`'s `Time.cpp` and this PR's test: 5 / 5 runs fail.

Pull request closed

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!17551
No description provided.