fix(kernel): validate error index pointer in sceKernelAprResolveFilepathsToIds #22108

Closed
Kikoarl wants to merge 1 commit from upstream-pr/22108 into main
Kikoarl commented 2026-11-17 05:33:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-11-17T05:33:54Z.


What

Validate error index guest pointer via GuestCopyOut_nid_no_patch in sceKernelAprResolveFilepathsToIds, preserving caller errno.

Tested

  • Code compiles cleanly in RAM-disk (/tmp/anyps5_build)
  • Unit test passing (guest_ampr_tests)
  • python3 tools/check_conventions.py --base origin/main passes cleanly

Checklist

  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5351418907 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22108). Originally posted by [Kikoarl](https://github.com/Kikoarl) on 2026-11-17T05:33:54Z. --- ### What Validate error index guest pointer via `GuestCopyOut_nid_no_patch` in `sceKernelAprResolveFilepathsToIds`, preserving caller errno. ### Tested - [x] Code compiles cleanly in RAM-disk (`/tmp/anyps5_build`) - [x] Unit test passing (`guest_ampr_tests`) - [x] `python3 tools/check_conventions.py --base origin/main` passes cleanly ### Checklist - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: none - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-17 05:35:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-17T05:35:29Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 781588cbb7:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_ampr_tests built cleanly.
  • CTest (guest_ampr_markers):
    1/1 Test #3354: guest_ampr_markers ...............   Passed    2.39 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libkernel/Apr/src/Apr.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #3354: guest_ampr_markers ...............***Exception: SegFault  2.73 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified pointer safety in sceKernelAprResolveFilepathsToIds: GuestCopyOut_nid_no_patch safely writes the error index to guest memory and returns false on invalid address without dereferencing in host space
    • Verified error code behavior: returns _fail(GUEST_EFAULT) (errno 14, return -1) if error_index is invalid guest memory, preserving host errno via savedErrno
    • Verified fallback error code: correctly returns _fail(GUEST_ENOENT) (errno 2, return -1) when resolution fails and error index copy succeeds or error_index is null
    • Verified debt documentation: docs/dev/debt/changes/fix-libkernel-apr-resolveFilepathsToIds-copyout.md correctly logs the functional change under libkernel Functional category
    • Verified unit test coverage in core/libs/tests/GuestAmpr.cpp: verifies both ENOENT and EFAULT when passed an unwritable guest pointer (0x10)

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5933490972 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22108#pullrequestreview-5933490972). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-17T05:35:29Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `781588cbb7`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_ampr_tests` built cleanly. - **CTest** (`guest_ampr_markers`): ``` 1/1 Test #3354: guest_ampr_markers ............... Passed 2.39 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libkernel/Apr/src/Apr.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #3354: guest_ampr_markers ...............***Exception: SegFault 2.73 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - Verified pointer safety in sceKernelAprResolveFilepathsToIds: GuestCopyOut_nid_no_patch safely writes the error index to guest memory and returns false on invalid address without dereferencing in host space - Verified error code behavior: returns _fail(GUEST_EFAULT) (errno 14, return -1) if error_index is invalid guest memory, preserving host errno via savedErrno - Verified fallback error code: correctly returns _fail(GUEST_ENOENT) (errno 2, return -1) when resolution fails and error index copy succeeds or error_index is null - Verified debt documentation: docs/dev/debt/changes/fix-libkernel-apr-resolveFilepathsToIds-copyout.md correctly logs the functional change under libkernel Functional category - Verified unit test coverage in core/libs/tests/GuestAmpr.cpp: verifies both ENOENT and EFAULT when passed an unwritable guest pointer (0x10) Looks Good To Me

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