test(libkernel): cover null pointer precedence in ktimer_settime #14695

Merged
slopgobblercobbler merged 1 commit from upstream-pr/14695 into main 2026-11-20 06:56:31 +00:00
slopgobblercobbler commented 2026-11-01 17:05:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by slopgobblercobbler on 2026-11-01T17:05:09Z.


What

Add negative test coverage in core/libs/tests/GuestKernelSysKtimer.cpp auditing ktimer_settime null pointer error precedence, verifying that a null value pointer returns -1 with errno set to EFAULT taking precedence over invalid timer IDs and flag arguments.

Tested

Verified against conventions with python tools/check_conventions.py --base upstream/main --head HEAD with 0 findings.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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:5109596039 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14695). Originally posted by [slopgobblercobbler](https://github.com/slopgobblercobbler) on 2026-11-01T17:05:09Z. --- ### What Add negative test coverage in `core/libs/tests/GuestKernelSysKtimer.cpp` auditing `ktimer_settime` null pointer error precedence, verifying that a null `value` pointer returns -1 with errno set to `EFAULT` taking precedence over invalid timer IDs and flag arguments. ### Tested Verified against conventions with `python tools/check_conventions.py --base upstream/main --head HEAD` with 0 findings. ### Checklist - [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) and the licence notice of code adapted from upstream (see AGENTS.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-11-01 20:45:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T20:45:56Z.

Review: COMMENTED


Reviewed — no blocking findings

The PR is titled as a test, but it also changes ktimer_settime: invalid flags now return EINVAL where the base accepted them. That change matches what the libkernel debt entry for this export already describes. The title and the debt wording should say so. The new assertions were compiled on the hosted Windows job but not run.

What I ran

  • Head e23b50f1970562e7f7f68f0f85196f655079af59; base f2d874c1fdccf781c0fa5d86619bb5dd8894b958. 2 files, +29/-0: Ktimer.cpp (+1) and GuestKernelSysKtimer.cpp (+28).
  • Read the full diff, the ktimer_settime function (Ktimer.cpp lines 119-135), TimerAbstime = 1 (line 26), and the test's new SettimeNegative function.
  • Order of checks in the new code: null itimerspec (EFAULT) first, then flags (EINVAL), then the timer id (EINVAL). The test's expectations follow that order, including invalid ids with a null value (EFAULT).
  • Debt entry docs/dev/debt/libkernel.md line 206 for this export lists EINVAL for "a bad itimerspec field, and TIMER_ABSTIME (1)". The new check is consistent with that list, but the entry does not say that every flag other than TIMER_ABSTIME is refused.
  • Precheck: diff check, conventions and PR template, and the live stack check passed. The ABI audit and test-quality rows failed on missing helpers; by hand the ABI audit is not applicable (no APS5 export changed).
  • Hosted: the windows job built guest_kernel_sys_ktimer_tests.exe, but its CTest run contains only conventions_ci_gate, and no step runs the guest binary. The relinker and linux jobs were skipped.
  • No MarcZX10 review at this head.

Results

Check Result Note
Diff check passed
Conventions and PR template passed precheck and hosted conventions passed
Mergeability and dependencies passed depends on none; the live stack check passed
Flag check in ktimer_settime passed matches the EINVAL item in the debt entry; behaviour change for invalid flags
Check order and test expectations passed null value first, then flags, then the id
Title and body needs change titled "test" but changes production behaviour (non-blocking)
ABI audit (manual run) not applicable no APS5 export changed
Guest test run, hosted not run the binary was built on Windows but not run; linux and relinker skipped
Build and runtime tests not run no build here
Negative controls not run no build here
Hosted CI passed (no test run) windows, conventions, labels, library-portability, intake and report passed; linux, relinker, relinker-asan, register-context and write-watch skipped
Commands and unedited precheck output

Commands:

  • Precheck: python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14695 --output-dir <scratch>/precheck/14695p (report.md in that directory).
  • Head fetched by URL (objects only): git fetch https://github.com/boykopovar/AnyPS5.git pull/14695/head.
  • Hosted checks: gh api repos/boykopovar/AnyPS5/commits/e23b50f1970562e7f7f68f0f85196f655079af59/check-runs; Windows log: the windows job of that run (one CTest case, then the guest binary listed without a run step).

Precheck table (unedited):

Check Status Command / reason
build_and_compile not_applicable The precheck deliberately does not configure, build, or compile AnyPS5.
diff_check passed git diff --check f2d874c1fdccf781c0fa5d86619bb5dd8894b958...e23b50f1970562e7f7f68f0f85196f655079af59
conventions_and_pr_template passed /marc/DeusMachina_0x1914/.venv/bin/python3 tools/check_conventions.py --base f2d874c1fdccf781c0fa5d86619bb5dd8894b958 --head e23b50f1970562e7f7f68f0f85196f655079af59 --title test(libkernel): cover null pointer and invalid flags in ktimer_settime --body /dev/shm/reviewer-run/precheck/14695p/pr-body.md
changed_export_abi_audit failed /marc/DeusMachina_0x1914/.venv/bin/python3 tools/pr_abi_audit.py --base f2d874c1fdccf781c0fa5d86619bb5dd8894b958 --head e23b50f1970562e7f7f68f0f85196f655079af59 --json
python_syntax not_applicable No changed Python implementation files.
related_python_unit_tests not_applicable No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.
python_test_registration not_applicable No changed test_*.py files.
live_dependency_and_mergeability_check passed /marc/DeusMachina_0x1914/.venv/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14695 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14695p/stack
build_dependent_cpp_tests not_applicable Not run: C++ tests need exact-head binaries, which require a build; the precheck does not build.
test_quality_heuristics failed /marc/DeusMachina_0x1914/.venv/bin/python3 /dev/shm/reviewer-run/precheck/14695p/head-e23b50f19705-ac8bd8ce/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/14695p/head-e23b50f19705-ac8bd8ce --json core/libs/prx/libkernel/Time/Ktimer.cpp core/libs/tests/GuestKernelSysKtimer.cpp
negative_controls not_applicable No changed Python test module in tools/ can be run as a no-build base-source control.

Negative control

Not run here. The guest test needs a build and a run.

Findings

Blocking

None.

Non-blocking

  • The title is "test(libkernel): cover null pointer and invalid flags in ktimer_settime", but the diff changes behaviour: Ktimer.cpp line 121 now returns EINVAL for any flag other than TIMER_ABSTIME, where the base accepted all flags. Please retitle it as a fix and state the behaviour change in the "What" section.
  • Debt entry docs/dev/debt/libkernel.md line 206 lists "TIMER_ABSTIME (1)" among the EINVAL conditions, which does not say that other flags are refused. Please state "flags other than TIMER_ABSTIME (1)" so the entry matches the code.
  • The new assertions were compiled on the Windows job, but no step ran them. A run on the linux job, or an explicit local run, would show the EINVAL and EFAULT expectations pass.

Sources

Not verified

  • No build or run here.
  • Whether the console's own ktimer_settime refuses all other flags was not measured; the check follows the debt entry's cited FreeBSD behaviour, which I did not re-read.
  • The guest test was not run hosted.

To get this to a good state

  • Nothing blocking. Retitle the PR and state the behaviour change, and align the debt wording. A run of the guest test would confirm the expectations.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5730190034 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14695#pullrequestreview-5730190034). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-01T20:45:56Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The PR is titled as a test, but it also changes `ktimer_settime`: invalid flags now return EINVAL where the base accepted them. That change matches what the libkernel debt entry for this export already describes. The title and the debt wording should say so. The new assertions were compiled on the hosted Windows job but not run. ## What I ran - Head `e23b50f1970562e7f7f68f0f85196f655079af59`; base `f2d874c1fdccf781c0fa5d86619bb5dd8894b958`. 2 files, +29/-0: `Ktimer.cpp` (+1) and `GuestKernelSysKtimer.cpp` (+28). - Read the full diff, the `ktimer_settime` function (`Ktimer.cpp` lines 119-135), `TimerAbstime = 1` (line 26), and the test's new `SettimeNegative` function. - Order of checks in the new code: null `itimerspec` (EFAULT) first, then flags (EINVAL), then the timer id (EINVAL). The test's expectations follow that order, including invalid ids with a null value (EFAULT). - Debt entry `docs/dev/debt/libkernel.md` line 206 for this export lists EINVAL for "a bad `itimerspec` field, and `TIMER_ABSTIME` (1)". The new check is consistent with that list, but the entry does not say that every flag other than `TIMER_ABSTIME` is refused. - Precheck: diff check, conventions and PR template, and the live stack check passed. The ABI audit and test-quality rows failed on missing helpers; by hand the ABI audit is not applicable (no APS5 export changed). - Hosted: the windows job built `guest_kernel_sys_ktimer_tests.exe`, but its CTest run contains only `conventions_ci_gate`, and no step runs the guest binary. The relinker and linux jobs were skipped. - No MarcZX10 review at this head. ## Results | Check | Result | Note | | --- | --- | --- | | Diff check | passed | | | Conventions and PR template | passed | precheck and hosted conventions passed | | Mergeability and dependencies | passed | depends on none; the live stack check passed | | Flag check in `ktimer_settime` | passed | matches the EINVAL item in the debt entry; behaviour change for invalid flags | | Check order and test expectations | passed | null value first, then flags, then the id | | Title and body | needs change | titled "test" but changes production behaviour (non-blocking) | | ABI audit (manual run) | not applicable | no APS5 export changed | | Guest test run, hosted | not run | the binary was built on Windows but not run; linux and relinker skipped | | Build and runtime tests | not run | no build here | | Negative controls | not run | no build here | | Hosted CI | passed (no test run) | windows, conventions, labels, library-portability, intake and report passed; linux, relinker, relinker-asan, register-context and write-watch skipped | <details><summary>Commands and unedited precheck output</summary> Commands: - Precheck: `python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14695 --output-dir <scratch>/precheck/14695p` (report.md in that directory). - Head fetched by URL (objects only): `git fetch https://github.com/boykopovar/AnyPS5.git pull/14695/head`. - Hosted checks: `gh api repos/boykopovar/AnyPS5/commits/e23b50f1970562e7f7f68f0f85196f655079af59/check-runs`; Windows log: the windows job of that run (one CTest case, then the guest binary listed without a run step). Precheck table (unedited): | Check | Status | Command / reason | |---|---|---| | build_and_compile | not_applicable | `The precheck deliberately does not configure, build, or compile AnyPS5.` | | diff_check | passed | `git diff --check f2d874c1fdccf781c0fa5d86619bb5dd8894b958...e23b50f1970562e7f7f68f0f85196f655079af59` | | conventions_and_pr_template | passed | `/marc/DeusMachina_0x1914/.venv/bin/python3 tools/check_conventions.py --base f2d874c1fdccf781c0fa5d86619bb5dd8894b958 --head e23b50f1970562e7f7f68f0f85196f655079af59 --title test(libkernel): cover null pointer and invalid flags in ktimer_settime --body /dev/shm/reviewer-run/precheck/14695p/pr-body.md` | | changed_export_abi_audit | failed | `/marc/DeusMachina_0x1914/.venv/bin/python3 tools/pr_abi_audit.py --base f2d874c1fdccf781c0fa5d86619bb5dd8894b958 --head e23b50f1970562e7f7f68f0f85196f655079af59 --json` | | python_syntax | not_applicable | `No changed Python implementation files.` | | related_python_unit_tests | not_applicable | `No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.` | | python_test_registration | not_applicable | `No changed test_*.py files.` | | live_dependency_and_mergeability_check | passed | `/marc/DeusMachina_0x1914/.venv/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14695 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14695p/stack` | | build_dependent_cpp_tests | not_applicable | `Not run: C++ tests need exact-head binaries, which require a build; the precheck does not build.` | | test_quality_heuristics | failed | `/marc/DeusMachina_0x1914/.venv/bin/python3 /dev/shm/reviewer-run/precheck/14695p/head-e23b50f19705-ac8bd8ce/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/14695p/head-e23b50f19705-ac8bd8ce --json core/libs/prx/libkernel/Time/Ktimer.cpp core/libs/tests/GuestKernelSysKtimer.cpp` | | negative_controls | not_applicable | `No changed Python test module in tools/ can be run as a no-build base-source control.` | </details> ## Negative control Not run here. The guest test needs a build and a run. ## Findings **Blocking** None. **Non-blocking** - The title is "test(libkernel): cover null pointer and invalid flags in ktimer_settime", but the diff changes behaviour: `Ktimer.cpp` line 121 now returns EINVAL for any flag other than `TIMER_ABSTIME`, where the base accepted all flags. Please retitle it as a fix and state the behaviour change in the "What" section. - Debt entry `docs/dev/debt/libkernel.md` line 206 lists "`TIMER_ABSTIME` (1)" among the EINVAL conditions, which does not say that other flags are refused. Please state "flags other than `TIMER_ABSTIME` (1)" so the entry matches the code. - The new assertions were compiled on the Windows job, but no step ran them. A run on the linux job, or an explicit local run, would show the EINVAL and EFAULT expectations pass. ## Sources - Flag check: https://github.com/boykopovar/AnyPS5/blob/e23b50f1970562e7f7f68f0f85196f655079af59/core/libs/prx/libkernel/Time/Ktimer.cpp#L119-L135 - New tests: https://github.com/boykopovar/AnyPS5/blob/e23b50f1970562e7f7f68f0f85196f655079af59/core/libs/tests/GuestKernelSysKtimer.cpp#L98-L124 - Debt entry: https://github.com/boykopovar/AnyPS5/blob/e23b50f1970562e7f7f68f0f85196f655079af59/docs/dev/debt/libkernel.md#L206 ## Not verified - No build or run here. - Whether the console's own `ktimer_settime` refuses all other flags was not measured; the check follows the debt entry's cited FreeBSD behaviour, which I did not re-read. - The guest test was not run hosted. ## To get this to a good state - Nothing blocking. Retitle the PR and state the behaviour change, and align the debt wording. A run of the guest test would confirm the expectations.
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!14695
No description provided.