fix(libkernel): reject invalid flags in ktimer_settime #12281

Merged
fogydes merged 1 commit from upstream-pr/12281 into main 2026-11-02 13:36:44 +00:00
fogydes commented 2026-10-28 07:06:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-10-28T07:06:00Z.


What

Reject unrecognized flags in ktimer_settime with EINVAL (FreeBSD sys/kern/kern_time.c: if ((flags & ~TIMER_ABSTIME) != 0) return (EINVAL);), matching the documented behavior in docs/dev/debt/libkernel.md:186. Previously, ktimer_settime_nid_postfix accepted arbitrary flag bits without validation. Added unit test cases for invalid flag values in guest_kernel_sys_ktimer.

Tested

Windows 11, ctest --test-dir build -R guest_kernel_sys_ktimer -V passed. Red control verified on unpatched Ktimer.cpp failing at core/libs/tests/GuestKernelSysKtimer.cpp:107. python tools/check_conventions.py --base origin/main passed. python tools/pr_overlap.py --branch fix/ktimer-settime-invalid-flags reported no overlap.

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:5046597225 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12281). Originally posted by [fogydes](https://github.com/fogydes) on 2026-10-28T07:06:00Z. --- ### What Reject unrecognized flags in `ktimer_settime` with `EINVAL` (FreeBSD `sys/kern/kern_time.c`: `if ((flags & ~TIMER_ABSTIME) != 0) return (EINVAL);`), matching the documented behavior in `docs/dev/debt/libkernel.md:186`. Previously, `ktimer_settime_nid_postfix` accepted arbitrary flag bits without validation. Added unit test cases for invalid flag values in `guest_kernel_sys_ktimer`. ### 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. --> Windows 11, `ctest --test-dir build -R guest_kernel_sys_ktimer -V` passed. Red control verified on unpatched `Ktimer.cpp` failing at `core/libs/tests/GuestKernelSysKtimer.cpp:107`. `python tools/check_conventions.py --base origin/main` passed. `python tools/pr_overlap.py --branch fix/ktimer-settime-invalid-flags` reported no overlap. ### 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
MarcZX10 commented 2026-10-28 08:53:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T08:53:08Z.

Review: APPROVED


The check rejects every bit outside TIMER_ABSTIME after the existing null-value fault check and before timer lookup/update, so invalid requests do not mutate timer state. The test covers negative flags and several unsupported bits with EINVAL; Windows CI and conventions pass, and the author reports ten Linux/WSL runs against a clean main control. The check matches the project’s FreeBSD-based behavior for unsupported flags. No blocking issue found.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5680015383 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12281#pullrequestreview-5680015383). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T08:53:08Z. **Review:** APPROVED --- The check rejects every bit outside `TIMER_ABSTIME` after the existing null-value fault check and before timer lookup/update, so invalid requests do not mutate timer state. The test covers negative flags and several unsupported bits with EINVAL; Windows CI and conventions pass, and the author reports ten Linux/WSL runs against a clean main control. The check matches the project’s FreeBSD-based behavior for unsupported flags. No blocking issue found.
MarcZX10 commented 2026-10-28 09:28:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T09:28:24Z.

Review: APPROVED


Rechecked the new head bdf916d924d8. The additional invalid-flag cases are appropriate and retain the earlier state-preservation/validation-order behavior. Hosted Windows, conventions, and report checks pass; the exact-head Linux control run was also reported. No blocker found.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5680443766 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12281#pullrequestreview-5680443766). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T09:28:24Z. **Review:** APPROVED --- Rechecked the new head `bdf916d924d8`. The additional invalid-flag cases are appropriate and retain the earlier state-preservation/validation-order behavior. Hosted Windows, conventions, and report checks pass; the exact-head Linux control run was also reported. No blocker found.
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!12281
No description provided.