fix(libkernel): return EFAULT from sceKernelGetAllowedSdkVersionOnSystem for an unwritable store #13790

Merged
DeveshB-1 merged 2 commits from upstream-pr/13790 into main 2026-11-01 01:23:24 +00:00
DeveshB-1 commented 2026-10-31 06:37:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DeveshB-1 on 2026-10-31T06:37:10Z.


What

Safely copy the allowed SDK version in sceKernelGetAllowedSdkVersionOnSystem using GuestCopyOut_nid_no_patch so that unwritable output pointers return SCE_KERNEL_ERROR_EFAULT (0x8002000e) without clobbering errno instead of crashing the host process with SIGSEGV.

Tested

Linux x86_64 (AMD Ryzen 7 7730U):

  • guest_software_version passes 3 of 3 (ctest --test-dir build -R '^guest_software_version$' --repeat until-fail:3 -V).
  • Negative control: on unmodified main, passing an unwritable pointer to sceKernelGetAllowedSdkVersionOnSystem crashes deterministically with SIGSEGV (***Exception: SegFault 0.08 sec). With this fix applied, it safely returns SCE_KERNEL_ERROR_EFAULT (0x8002000e) and preserves errno.
  • python3 tools/check_conventions.py --base origin/main reports zero findings.
  • python3 tools/pr_overlap.py --branch fix/allowed-sdk-version-efault reports no conflicting open pull requests implementing the same functions.

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:5095266040 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13790). Originally posted by [DeveshB-1](https://github.com/DeveshB-1) on 2026-10-31T06:37:10Z. --- ### What Safely copy the allowed SDK version in `sceKernelGetAllowedSdkVersionOnSystem` using `GuestCopyOut_nid_no_patch` so that unwritable output pointers return `SCE_KERNEL_ERROR_EFAULT` (`0x8002000e`) without clobbering `errno` instead of crashing the host process with `SIGSEGV`. ### Tested Linux x86_64 (AMD Ryzen 7 7730U): - `guest_software_version` passes 3 of 3 (`ctest --test-dir build -R '^guest_software_version$' --repeat until-fail:3 -V`). - Negative control: on unmodified `main`, passing an unwritable pointer to `sceKernelGetAllowedSdkVersionOnSystem` crashes deterministically with `SIGSEGV` (`***Exception: SegFault 0.08 sec`). With this fix applied, it safely returns `SCE_KERNEL_ERROR_EFAULT` (`0x8002000e`) and preserves `errno`. - `python3 tools/check_conventions.py --base origin/main` reports zero findings. - `python3 tools/pr_overlap.py --branch fix/allowed-sdk-version-efault` reports no conflicting open pull requests implementing the same functions. ### 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-31 07:02:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T07:02:56Z.

Review: APPROVED


Reviewed — looks good

I found no blocking issue in head ade08a31e19a80756036acb509f1ef64b8e68053; the function uses the checked guest-memory copy and preserves errno on the failure path.

What I ran

Reviewed head ade08a31e19a80756036acb509f1ef64b8e68053 against PR base snapshot 833be4af8ddcf695bfabc6f8110fb42b4e15e6c7. The merge preview against current main de83e8f27015b91327029755f1ea5b60b74d940b was clean. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. No local build or CTest.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13790
git diff --check 833be4af8ddcf695bfabc6f8110fb42b4e15e6c7...ade08a31e19a80756036acb509f1ef64b8e68053
python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 833be4af8ddcf695bfabc6f8110fb42b4e15e6c7 --head ade08a31e19a80756036acb509f1ef64b8e68053 --json
python3 tools/pr_test_quality.py --root /marc/AnyPS5 --json core/libs/tests/GuestSoftwareVersion.cpp
python3 tools/pr_stack_check.py 13790 --repo boykopovar/AnyPS5
git merge-tree --write-tree de83e8f27015b91327029755f1ea5b60b74d940b ade08a31e19a80756036acb509f1ef64b8e68053
gh run view 41177360238 --repo boykopovar/AnyPS5 --job 124467786629 --log | grep -E 'SoftwareVersion.cpp.obj|No guest|libs build'

Results

Check Result
Diff and conventions/template Passed.
ABI audit No findings; the source audit does not verify binary ABI or compilation.
Test registration The heuristic warned about registration; exact-head core/libs/prx/libkernel/CMakeLists.txt registers guest_software_version.
Current-main merge preview Clean; git merge-tree returned f8be2a6a0570ad752654a95c2271e99d63b5ae1f.
Hosted CI Windows passed and compiled SoftwareVersion.cpp; its test-selection step skipped guest_software_version. Linux and specialized jobs were skipped.
Author-reported tests The PR reports Linux guest_software_version passing 3/3 and the test failing against unmodified main. The tested SHA is not stated; I did not independently run these tests.
Precheck helper limitations Its isolated checkout lacks the local-only ABI and test-quality helper scripts; I reran those checks from the workspace.
Unedited output from checks

Precheck conventions output:

All conventions checks passed.

ABI audit output:

{
  "status": "passed",
  "symbols": [
    {
      "name": "sceKernelGetAllowedSdkVersionOnSystem_nid_postfix",
      "computed_nid": "YeU23Szo3BM",
      "declarations": [
        "core/libs/prx/libkernel/include/Api.hpp"
      ],
      "definitions": [
        "core/libs/prx/libkernel/System/src/SoftwareVersion.cpp"
      ],
      "explicit_aliases": [],
      "version": "not encoded by these source declarations; not verified"
    },
    {
      "name": "sceKernelGetProsperoSystemSwVersion_nid_postfix",
      "computed_nid": "aML18Z0J0t0",
      "declarations": [
        "core/libs/prx/libkernel/include/Api.hpp"
      ],
      "definitions": [
        "core/libs/prx/libkernel/System/src/SoftwareVersion.cpp"
      ],
      "explicit_aliases": [],
      "version": "not encoded by these source declarations; not verified"
    }
  ],
  "findings": [],
  "limitations": [
    "This lexical audit does not parse C++ fully, prove calling-convention or binary ABI correctness, verify runtime version tables, or replace compilation.",
    "An absent source declaration or explicit alias can be intentional for assembly exports, conditional platform code, or generated interfaces; inspect findings before treating them as defects."
  ]
}

Test-quality output:

{
  "findings": [
    {
      "path": "core/libs/tests/GuestSoftwareVersion.cpp",
      "line": 1,
      "kind": "possible-unregistered-cpp-test",
      "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."
    }
  ],
  "negative_control_candidates": [],
  "limits": [
    "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.",
    "A test that passes against base is not by itself proof that the PR test is inadequate.",
    "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error."
  ]
}

Isolated-checkout helper errors:

/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13790-ade08a31e19a/head-ade08a31e19a-c90a6239/tools/pr_abi_audit.py': [Errno 2] No such file or directory
/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13790-ade08a31e19a/head-ade08a31e19a-c90a6239/tools/pr_test_quality.py': [Errno 2] No such file or directory

Merge preview output:

f8be2a6a0570ad752654a95c2271e99d63b5ae1f

Windows build and test-selection log excerpts:

windows	Build and run changed guest core/libs tests	2026-10-31T06:46:01.6462866Z [700/2783] Building CXX object core/libs/prx/libkernel/CMakeFiles/libkernel.dir/System/src/SoftwareVersion.cpp.obj
windows	Build and run changed guest core/libs tests	2026-10-31T06:47:55.5258898Z No guest core/libs test sources changed
windows	Build and run changed guest core/libs tests	2026-10-31T06:47:55.5259551Z No guest core/libs test sources changed; the libs build still ran

Not verified

No local build or CTest and no PS5 console behavior were verified. The author-reported Linux tests were not independently reproduced; hosted Windows did not run the focused test.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5721731996 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13790#pullrequestreview-5721731996). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T07:02:56Z. **Review:** APPROVED --- # Reviewed — looks good I found no blocking issue in head `ade08a31e19a80756036acb509f1ef64b8e68053`; the function uses the checked guest-memory copy and preserves `errno` on the failure path. ## What I ran Reviewed head `ade08a31e19a80756036acb509f1ef64b8e68053` against PR base snapshot `833be4af8ddcf695bfabc6f8110fb42b4e15e6c7`. The merge preview against current `main` `de83e8f27015b91327029755f1ea5b60b74d940b` was clean. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. No local build or CTest. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13790 git diff --check 833be4af8ddcf695bfabc6f8110fb42b4e15e6c7...ade08a31e19a80756036acb509f1ef64b8e68053 python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 833be4af8ddcf695bfabc6f8110fb42b4e15e6c7 --head ade08a31e19a80756036acb509f1ef64b8e68053 --json python3 tools/pr_test_quality.py --root /marc/AnyPS5 --json core/libs/tests/GuestSoftwareVersion.cpp python3 tools/pr_stack_check.py 13790 --repo boykopovar/AnyPS5 git merge-tree --write-tree de83e8f27015b91327029755f1ea5b60b74d940b ade08a31e19a80756036acb509f1ef64b8e68053 gh run view 41177360238 --repo boykopovar/AnyPS5 --job 124467786629 --log | grep -E 'SoftwareVersion.cpp.obj|No guest|libs build' ``` ## Results | Check | Result | |---|---| | Diff and conventions/template | Passed. | | ABI audit | No findings; the source audit does not verify binary ABI or compilation. | | Test registration | The heuristic warned about registration; exact-head `core/libs/prx/libkernel/CMakeLists.txt` registers `guest_software_version`. | | Current-main merge preview | Clean; `git merge-tree` returned `f8be2a6a0570ad752654a95c2271e99d63b5ae1f`. | | Hosted CI | Windows passed and compiled `SoftwareVersion.cpp`; its test-selection step skipped `guest_software_version`. Linux and specialized jobs were skipped. | | Author-reported tests | The PR reports Linux `guest_software_version` passing 3/3 and the test failing against unmodified `main`. The tested SHA is not stated; I did not independently run these tests. | | Precheck helper limitations | Its isolated checkout lacks the local-only ABI and test-quality helper scripts; I reran those checks from the workspace. | <details><summary>Unedited output from checks</summary> Precheck conventions output: ```text All conventions checks passed. ``` ABI audit output: ```json { "status": "passed", "symbols": [ { "name": "sceKernelGetAllowedSdkVersionOnSystem_nid_postfix", "computed_nid": "YeU23Szo3BM", "declarations": [ "core/libs/prx/libkernel/include/Api.hpp" ], "definitions": [ "core/libs/prx/libkernel/System/src/SoftwareVersion.cpp" ], "explicit_aliases": [], "version": "not encoded by these source declarations; not verified" }, { "name": "sceKernelGetProsperoSystemSwVersion_nid_postfix", "computed_nid": "aML18Z0J0t0", "declarations": [ "core/libs/prx/libkernel/include/Api.hpp" ], "definitions": [ "core/libs/prx/libkernel/System/src/SoftwareVersion.cpp" ], "explicit_aliases": [], "version": "not encoded by these source declarations; not verified" } ], "findings": [], "limitations": [ "This lexical audit does not parse C++ fully, prove calling-convention or binary ABI correctness, verify runtime version tables, or replace compilation.", "An absent source declaration or explicit alias can be intentional for assembly exports, conditional platform code, or generated interfaces; inspect findings before treating them as defects." ] } ``` Test-quality output: ```json { "findings": [ { "path": "core/libs/tests/GuestSoftwareVersion.cpp", "line": 1, "kind": "possible-unregistered-cpp-test", "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage." } ], "negative_control_candidates": [], "limits": [ "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.", "A test that passes against base is not by itself proof that the PR test is inadequate.", "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error." ] } ``` Isolated-checkout helper errors: ```text /usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13790-ade08a31e19a/head-ade08a31e19a-c90a6239/tools/pr_abi_audit.py': [Errno 2] No such file or directory /usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13790-ade08a31e19a/head-ade08a31e19a-c90a6239/tools/pr_test_quality.py': [Errno 2] No such file or directory ``` Merge preview output: ```text f8be2a6a0570ad752654a95c2271e99d63b5ae1f ``` Windows build and test-selection log excerpts: ```text windows Build and run changed guest core/libs tests 2026-10-31T06:46:01.6462866Z [700/2783] Building CXX object core/libs/prx/libkernel/CMakeFiles/libkernel.dir/System/src/SoftwareVersion.cpp.obj windows Build and run changed guest core/libs tests 2026-10-31T06:47:55.5258898Z No guest core/libs test sources changed windows Build and run changed guest core/libs tests 2026-10-31T06:47:55.5259551Z No guest core/libs test sources changed; the libs build still ran ``` </details> ## Not verified No local build or CTest and no PS5 console behavior were verified. The author-reported Linux tests were not independently reproduced; hosted Windows did not run the focused test.
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!13790
No description provided.