fix(libkernel): return EFAULT from sceKernelGetAppInfo for invalid memory pointers #13798

Merged
pushkarreddyy merged 6 commits from upstream-pr/13798 into main 2026-11-01 01:22:04 +00:00
pushkarreddyy commented 2026-10-31 07:12:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-31T07:12:52Z.


What

Fixes #13795.
sceKernelGetAppInfo directly dereferenced the guest output pointer info via std::memset and std::memcpy. When a guest passed a non-null pointer into unmapped or read-only memory, the host process crashed with SIGSEGV / 0xC0000005.

This change:

  • Formats the 0x58-byte application info record locally and writes to destination memory using WriteGuest.
  • Returns SCE_KERNEL_ERROR_EFAULT (0x8002000e) when destination memory is inaccessible.
  • Adds regression unit tests in core/libs/tests/GuestAppInfo.cpp covering invalid destination pointers (0x10) for both current PID and PID 0.
  • Documents the host-safety fallback in docs/dev/debt/libkernel.md.

Tested

  • Ran python tools/check_conventions.py --base origin/main.
  • Added unit tests in core/libs/tests/GuestAppInfo.cpp asserting sceKernelGetAppInfo returns SCE_KERNEL_ERROR_EFAULT on invalid memory.

Checklist

  • What
  • Tested
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5095477111 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13798). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-31T07:12:52Z. --- ### What Fixes #13795. `sceKernelGetAppInfo` directly dereferenced the guest output pointer `info` via `std::memset` and `std::memcpy`. When a guest passed a non-null pointer into unmapped or read-only memory, the host process crashed with `SIGSEGV` / `0xC0000005`. This change: - Formats the 0x58-byte application info record locally and writes to destination memory using `WriteGuest`. - Returns `SCE_KERNEL_ERROR_EFAULT` (`0x8002000e`) when destination memory is inaccessible. - Adds regression unit tests in `core/libs/tests/GuestAppInfo.cpp` covering invalid destination pointers (`0x10`) for both current PID and PID 0. - Documents the host-safety fallback in `docs/dev/debt/libkernel.md`. ### Tested - Ran `python tools/check_conventions.py --base origin/main`. - Added unit tests in `core/libs/tests/GuestAppInfo.cpp` asserting `sceKernelGetAppInfo` returns `SCE_KERNEL_ERROR_EFAULT` on invalid memory. ### Checklist - [x] What - [x] Tested - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
jotitadev commented 2026-10-31 09:36:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-31T09:36:56Z.

Review: COMMENTED


Linux run of head bed3f89b7, merged (--no-commit) onto main 809c7fa2df. Ubuntu 26.04 (kernel 7.0), GCC 15.2.0, CMake 4.2.3, Ninja, Release, BUILD_TESTING=ON, i7-8700.

  • guest_app_info passes 3/3.
  • Full build ok. public_headers: 65/65. Subset guest_app_info|guest_process|guest_kernel_sys|guest_getgroups|trinity: 36/36.
  • Red: with Process.cpp reverted to main and the new test kept, guest_app_info crashes (SEGFAULT) 3/3.
  • errno: with only the errno = savedErrno; line removed, guest_app_info aborts 3/3, so the new errno == 71 checks do catch the Linux leak.
  • This save/restore is still needed with #13664. #13664 only changes GuestCopyIn/GuestCopyOut in libc, and sceKernelGetAppInfo goes through libkernel's own WriteGuest in Process.cpp, which calls process_vm_writev directly. With main + #13664 + this PR, minus the two savedErrno lines, guest_app_info still aborts 3/3.
  • main + #13769 + #13798 (both touch Process.cpp): clean, full build ok, the subset 36/36 three times, public_headers 65/65.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5722200304 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13798#pullrequestreview-5722200304). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-31T09:36:56Z. **Review:** COMMENTED --- Linux run of head `bed3f89b7`, merged (`--no-commit`) onto `main` `809c7fa2df`. Ubuntu 26.04 (kernel 7.0), GCC 15.2.0, CMake 4.2.3, Ninja, Release, `BUILD_TESTING=ON`, i7-8700. - `guest_app_info` passes 3/3. - Full build ok. `public_headers`: 65/65. Subset `guest_app_info|guest_process|guest_kernel_sys|guest_getgroups|trinity`: 36/36. - Red: with `Process.cpp` reverted to `main` and the new test kept, `guest_app_info` crashes (SEGFAULT) 3/3. - errno: with only the `errno = savedErrno;` line removed, `guest_app_info` aborts 3/3, so the new `errno == 71` checks do catch the Linux leak. - This save/restore is still needed with #13664. #13664 only changes `GuestCopyIn`/`GuestCopyOut` in libc, and `sceKernelGetAppInfo` goes through libkernel's own `WriteGuest` in `Process.cpp`, which calls `process_vm_writev` directly. With `main` + #13664 + this PR, minus the two `savedErrno` lines, `guest_app_info` still aborts 3/3. - `main` + #13769 + #13798 (both touch `Process.cpp`): clean, full build ok, the subset 36/36 three times, `public_headers` 65/65. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
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!13798
No description provided.