fix(libkernel): return ENOENT for unknown sysctl names #8910

Merged
DoubleAAGuy merged 3 commits from upstream-pr/8910 into main 2026-10-23 18:33:31 +00:00
DoubleAAGuy commented 2026-10-21 05:43:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DoubleAAGuy on 2026-10-21T05:43:15Z.


What

Return -1/ENOENT instead of throwing when sysctlbyname or sysctlnametomib cannot resolve a name. A PS5 payload (firmware 12.70) measured kern.anyps5_no_such_name returning ENOENT; the implementation generalizes this to unknown names, consistent with FreeBSD lookup semantics, without special-casing the observed string. Tests ensure failed lookups leave caller buffers and lengths unchanged. Unknown numeric MIBs retain their current throwing behavior.

The exact behavior for other unknown names in title processes is unverified.

Tested

Linux Ubuntu 22.04, aarch64, GCC 11.4:

  • python3 tools/check_conventions.py --base origin/main passed.
  • GCC syntax checks passed for the implementation and GuestSystemConfiguration tests.
  • A focused native smoke test passed for unknown sysctlbyname and sysctlnametomib calls, including ENOENT and output preservation. The harness supplied stubs for unrelated runtime dependencies.
  • Full project CMake/CTest was not run: the Linux host lacks Ninja and the full Makefile configure is blocked by missing Xext.h. No title run was possible.
  • Independent Windows 11 / MinGW64 review on rebased head 40680ca1e: guest_system_configuration passed; baseline failed the new unknown-name assertion as expected. The Windows reviewer reports a focused test, not a title run.

Overlap review

python3 tools/pr_overlap.py --branch fix/libkernel-unknown-sysctl-enoent --repo boykopovar/AnyPS5 found no confirmed duplicate behavior or overlapping changed lines. PR #8553 also touches sysctlnametomib, but adds measured mappings for four known names in its lookup table; this PR only handles unresolved names after known-name lookup. Its tests and debt hunk are separate. PR #9199 has a documentation hunk overlap on other sysctl entries; its author agreed #8910 can merge first and will rebase #9199 afterwards. PR #6044 moves core/libs/tests/GuestSystemConfiguration.cpp; if it merges first, this test change will need a path rebase.

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
  • 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:4946991074 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8910). Originally posted by [DoubleAAGuy](https://github.com/DoubleAAGuy) on 2026-10-21T05:43:15Z. --- ### What Return `-1`/`ENOENT` instead of throwing when `sysctlbyname` or `sysctlnametomib` cannot resolve a name. A PS5 payload (firmware 12.70) measured `kern.anyps5_no_such_name` returning `ENOENT`; the implementation generalizes this to unknown names, consistent with FreeBSD lookup semantics, without special-casing the observed string. Tests ensure failed lookups leave caller buffers and lengths unchanged. Unknown numeric MIBs retain their current throwing behavior. The exact behavior for other unknown names in title processes is unverified. ### Tested Linux Ubuntu 22.04, aarch64, GCC 11.4: - `python3 tools/check_conventions.py --base origin/main` passed. - GCC syntax checks passed for the implementation and `GuestSystemConfiguration` tests. - A focused native smoke test passed for unknown `sysctlbyname` and `sysctlnametomib` calls, including `ENOENT` and output preservation. The harness supplied stubs for unrelated runtime dependencies. - Full project CMake/CTest was not run: the Linux host lacks Ninja and the full Makefile configure is blocked by missing `Xext.h`. No title run was possible. - Independent Windows 11 / MinGW64 review on rebased head `40680ca1e`: `guest_system_configuration` passed; baseline failed the new unknown-name assertion as expected. The Windows reviewer reports a focused test, not a title run. <!-- 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. --> ### Overlap review `python3 tools/pr_overlap.py --branch fix/libkernel-unknown-sysctl-enoent --repo boykopovar/AnyPS5` found no confirmed duplicate behavior or overlapping changed lines. PR #8553 also touches `sysctlnametomib`, but adds measured mappings for four known names in its lookup table; this PR only handles unresolved names after known-name lookup. Its tests and debt hunk are separate. PR #9199 has a documentation hunk overlap on other sysctl entries; its author agreed #8910 can merge first and will rebase #9199 afterwards. PR #6044 moves `core/libs/tests/GuestSystemConfiguration.cpp`; if it merges first, this test change will need a path rebase. ### 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) - [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 -->
MarcZX10 commented 2026-10-21 05:49:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T05:49:06Z.

Review: APPROVED


Reviewed the unknown-name paths and the regression cases. Both sysctlbyname and sysctlnametomib now set guest ENOENT and return -1 without changing output storage or lengths; known-name paths and unknown numeric MIB behavior remain separate. The author reports a focused native smoke test and syntax checks, and clearly limits the console claim to the measured payload name. I did not run a full project build or title test.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5595460281 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8910#pullrequestreview-5595460281). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T05:49:06Z. **Review:** APPROVED --- Reviewed the unknown-name paths and the regression cases. Both `sysctlbyname` and `sysctlnametomib` now set guest `ENOENT` and return `-1` without changing output storage or lengths; known-name paths and unknown numeric MIB behavior remain separate. The author reports a focused native smoke test and syntax checks, and clearly limits the console claim to the measured payload name. I did not run a full project build or title test.
xXPBSXx commented 2026-10-21 10:34:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T10:34:59Z.


Windows data point for 39a60e421 merged onto main b77bd5880 (clean, git merge-tree rc 0; main has not touched SystemConfiguration.cpp or GuestSystemConfiguration.cpp since the merge base 1aad07054): Windows 10.0.19045, MinGW-w64 GCC 15.2.0, Release. ctest -N -R '^guest_system_configuration$' lists exactly that one test; ctest --no-tests=error was run three times on the PR tree.

  • With the PR: guest_system_configuration fails 3 of 3, exit code 0xc0000409 (abort).
  • main alone: the same test passes.
    I located the failing check by building a local copy of the test with the line number printed in Require: it is the Require(threw) in CheckNameToMib right after tooLong[1023] = 0; (line 783 of the merged file). That case expects sysctlnametomib_nid_postfix to throw std::runtime_error for a 1023-character name that is not served; I did not analyse how the change interacts with it. The new CheckUnknownSysctlName runs before it in main and was not the failing check.
    Not tested: Linux, a title run.
    AI-assisted (Claude Code).
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6313873370 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8910#issuecomment-6313873370). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T10:34:59Z. --- Windows data point for `39a60e421` merged onto `main` `b77bd5880` (clean, `git merge-tree` rc 0; `main` has not touched `SystemConfiguration.cpp` or `GuestSystemConfiguration.cpp` since the merge base `1aad07054`): Windows 10.0.19045, MinGW-w64 GCC 15.2.0, Release. `ctest -N -R '^guest_system_configuration$'` lists exactly that one test; `ctest --no-tests=error` was run three times on the PR tree. - With the PR: `guest_system_configuration` fails 3 of 3, exit code `0xc0000409` (abort). - `main` alone: the same test passes. I located the failing check by building a local copy of the test with the line number printed in `Require`: it is the `Require(threw)` in `CheckNameToMib` right after `tooLong[1023] = 0;` (line 783 of the merged file). That case expects `sysctlnametomib_nid_postfix` to throw `std::runtime_error` for a 1023-character name that is not served; I did not analyse how the change interacts with it. The new `CheckUnknownSysctlName` runs before it in `main` and was not the failing check. Not tested: Linux, a title run. AI-assisted (Claude Code).
DoubleAAGuy commented 2026-10-21 10:54:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DoubleAAGuy on 2026-10-21T10:54:16Z.


Thanks, that is a valid catch. The 1,024-character input still returns ENAMETOOLONG; after truncating it to 1,023 characters it is an ordinary unresolved name, so the new behavior is ENOENT. I updated the regression test to expect that and verify the output MIB remains untouched, then pushed commit 0c62af6cc. GCC syntax checks and the focused native smoke test pass; I cannot run the full CTest/Windows test here. Could you rerun guest_system_configuration on Windows when convenient?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6314202307 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8910#issuecomment-6314202307). Originally posted by [DoubleAAGuy](https://github.com/DoubleAAGuy) on 2026-10-21T10:54:16Z. --- Thanks, that is a valid catch. The 1,024-character input still returns `ENAMETOOLONG`; after truncating it to 1,023 characters it is an ordinary unresolved name, so the new behavior is `ENOENT`. I updated the regression test to expect that and verify the output MIB remains untouched, then pushed commit `0c62af6cc`. GCC syntax checks and the focused native smoke test pass; I cannot run the full CTest/Windows test here. Could you rerun `guest_system_configuration` on Windows when convenient?
THEMANnt commented 2026-10-23 03:02:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-23T03:02:34Z.

Review: APPROVED


Review: PR #8910

Head: 92e4d060b058d134c9efa7bc2ef8351dc51ce23a
Environment: Windows 11, MinGW64 toolchain, Python 3.11.9
Test Profile: guest_system_configuration

Verification Summary

✅ Baseline build & test: Passed (head b7d1d47a5f9f32c9c388ad8d47a0055a90ae6e33)
✅ Pristine PR build & test: Passed (head 92e4d060b058d134c9efa7bc2ef8351dc51ce23a)
✅ Candidate build & test: Passed (head 92e4d060b058d134c9efa7bc2ef8351dc51ce23a)
✅ Negative control: Correctly failed against baseline, confirming old throwing behavior
✅ Whitespace check: Passed
✅ Conventions check: Passed

Source Verification

The changes at SystemConfiguration.cpp:455-456 and 518-519 correctly:

  • Set *__error_nid_postfix() = 2 (ENOENT)
  • Return -1 without modifying output buffers or lengths

Test coverage in GuestSystemConfiguration.cpp adequately verifies:

  • Buffer preservation on error
  • Length invariance
  • errno values for both functions
  • Null output buffers, existing null-name checks, and oversized-name handling

Limitations

  • Local-only native test execution; no GPU or game-level verification
  • CTest registration verified for guest_system_configuration profile only

No actionable findings in this focused review. The changed unknown-name paths follow the existing libkernel errno/return-value convention.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5623406415 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8910#pullrequestreview-5623406415). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-23T03:02:34Z. **Review:** APPROVED --- ## Review: PR #8910 **Head:** `92e4d060b058d134c9efa7bc2ef8351dc51ce23a` **Environment:** Windows 11, MinGW64 toolchain, Python 3.11.9 **Test Profile:** `guest_system_configuration` ### Verification Summary ✅ **Baseline build & test:** Passed (head `b7d1d47a5f9f32c9c388ad8d47a0055a90ae6e33`) ✅ **Pristine PR build & test:** Passed (head `92e4d060b058d134c9efa7bc2ef8351dc51ce23a`) ✅ **Candidate build & test:** Passed (head `92e4d060b058d134c9efa7bc2ef8351dc51ce23a`) ✅ **Negative control:** Correctly failed against baseline, confirming old throwing behavior ✅ **Whitespace check:** Passed ✅ **Conventions check:** Passed ### Source Verification The changes at `SystemConfiguration.cpp:455-456` and `518-519` correctly: - Set `*__error_nid_postfix() = 2` (ENOENT) - Return `-1` without modifying output buffers or lengths Test coverage in `GuestSystemConfiguration.cpp` adequately verifies: - Buffer preservation on error - Length invariance - errno values for both functions - Null output buffers, existing null-name checks, and oversized-name handling ### Limitations - Local-only native test execution; no GPU or game-level verification - CTest registration verified for `guest_system_configuration` profile only No actionable findings in this focused review. The changed unknown-name paths follow the existing libkernel errno/return-value convention.
MarcZX10 commented 2026-10-23 06:13:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T06:13:51Z.

Review: APPROVED


Re-reviewed the rebased exact head 40680ca1e3df696f2382d03847608a1f5c0a7273. The three-commit change still returns -1/ENOENT for unresolved names in sysctlbyname and sysctlnametomib, preserves caller buffers and lengths, and keeps known-name handling and unknown numeric MIB behavior separate. The focused Windows guest_system_configuration run on this exact head is reported passing; current hosted eligibility/conventions/labels/report checks pass and product build jobs are skipped by policy. My local git diff --check and conventions pass; current-main sync is conflict-free (3 ahead/15 behind by local commit count). I did not run a full build or title test. The change remains limited to a measured payload result generalized to unknown names, with title behavior explicitly unverified.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5624613519 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8910#pullrequestreview-5624613519). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T06:13:51Z. **Review:** APPROVED --- Re-reviewed the rebased exact head `40680ca1e3df696f2382d03847608a1f5c0a7273`. The three-commit change still returns `-1`/`ENOENT` for unresolved names in `sysctlbyname` and `sysctlnametomib`, preserves caller buffers and lengths, and keeps known-name handling and unknown numeric MIB behavior separate. The focused Windows `guest_system_configuration` run on this exact head is reported passing; current hosted eligibility/conventions/labels/report checks pass and product build jobs are skipped by policy. My local `git diff --check` and conventions pass; current-main sync is conflict-free (3 ahead/15 behind by local commit count). I did not run a full build or title test. The change remains limited to a measured payload result generalized to unknown names, with title behavior explicitly unverified.
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!8910
No description provided.