fix(libkernel): return EFAULT from sceKernelStat and sceKernelUnlink for a null path #7108

Merged
pushkarreddyy merged 1 commit from upstream-pr/7108 into main 2026-10-17 14:23:32 +00:00
pushkarreddyy commented 2026-10-17 12:01:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-17T12:01:34Z.


What

sceKernelStat and sceKernelUnlink threw std::invalid_argument when passed a null path, terminating the calling title. In FreeBSD 11, sys_stat and sys_unlink return EFAULT (0x8002000e in PS5 errno) when the user path pointer cannot be copied from guest memory.

Both entry points now return 0x8002000e (SCE_KERNEL_ERROR_EFAULT) when path == nullptr instead of throwing.

Tested

Added unit tests in core/libs/tests/GuestPosixScalarIo.cpp (guest_posix_scalar_io) verifying that sceKernelStat and sceKernelUnlink with a null path fail with 0x8002000e without throwing.
python tools/check_conventions.py --base origin/main passed cleanly with zero findings.

Checklist

  • Conventional Commit title
  • Code follows the conventions in docs/dev/CONVENTIONS.md
  • Technical debt recorded in docs/dev/TechnicalDebt.md
  • Unit test added
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4899880411 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7108). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-17T12:01:34Z. --- ### What `sceKernelStat` and `sceKernelUnlink` threw `std::invalid_argument` when passed a null path, terminating the calling title. In FreeBSD 11, [`sys_stat`](https://github.com/freebsd/freebsd-src/blob/releng/11.0/sys/kern/vfs_syscalls.c#L2251) and [`sys_unlink`](https://github.com/freebsd/freebsd-src/blob/releng/11.0/sys/kern/vfs_syscalls.c#L1734) return `EFAULT` (`0x8002000e` in PS5 errno) when the user path pointer cannot be copied from guest memory. Both entry points now return `0x8002000e` (`SCE_KERNEL_ERROR_EFAULT`) when `path == nullptr` instead of throwing. ### Tested Added unit tests in `core/libs/tests/GuestPosixScalarIo.cpp` (`guest_posix_scalar_io`) verifying that `sceKernelStat` and `sceKernelUnlink` with a null path fail with `0x8002000e` without throwing. `python tools/check_conventions.py --base origin/main` passed cleanly with zero findings. ### Checklist - [x] Conventional Commit title - [x] Code follows the conventions in `docs/dev/CONVENTIONS.md` - [x] Technical debt recorded in `docs/dev/TechnicalDebt.md` - [x] Unit test added - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-17 12:16:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T12:16:57Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 core/libs/prx/libkernel/File/src/Open.cpp
PR 6044 core/libs/tests/GuestPosixScalarIo.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6233778644 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7108#issuecomment-6233778644). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-17T12:16:57Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libkernel/File/src/Open.cpp` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestPosixScalarIo.cpp` |
pushkarreddyy commented 2026-10-17 13:12:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-17T13:12:48Z.


Thank you @oneandonlydean for reviewing and merging #7103!

I have rebased #7108 directly onto latest origin/main (04788b090). As discussed on #7110 and #7113, once #7108 merges, I will immediately update #7110 with the folded changes (combining sceKernelTruncate, sceKernelUtimes, sceKernelMkdir, sceKernelRmdir, and sceKernelRename) and close #7113 and #7114.

Whenever you have a moment, please also check our other green PRs passing all CI checks:

  • #7133 (fix(libkernel): return EFAULT from sceKernelWriteThrottlingStatus for a null status) — fixes null status pointer fault on Minecraft Bedrock (PPSA17221, #5744).
  • #7125 (feat(libs): declare missing RUDP and signaling imports for PPSA31327) — unblocks start-up for Yakuza 0 Director's Cut (PPSA31327, #6722).
  • #7096 (ci(relinker): run TLS function coverage tests under ASan on Linux) — addresses #7062.
  • #7089 (fix(libSceAgcDriver): normalize reserved bit 30 in guest buffer descriptors) — addresses #7051.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6234293305 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7108#issuecomment-6234293305). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-17T13:12:48Z. --- Thank you @oneandonlydean for reviewing and merging #7103! I have rebased #7108 directly onto latest `origin/main` (`04788b090`). As discussed on #7110 and #7113, once #7108 merges, I will immediately update #7110 with the folded changes (combining `sceKernelTruncate`, `sceKernelUtimes`, `sceKernelMkdir`, `sceKernelRmdir`, and `sceKernelRename`) and close #7113 and #7114. Whenever you have a moment, please also check our other green PRs passing all CI checks: - #7133 (`fix(libkernel): return EFAULT from sceKernelWriteThrottlingStatus for a null status`) — fixes null status pointer fault on *Minecraft Bedrock* (`PPSA17221`, #5744). - #7125 (`feat(libs): declare missing RUDP and signaling imports for PPSA31327`) — unblocks start-up for *Yakuza 0 Director's Cut* (`PPSA31327`, #6722). - #7096 (`ci(relinker): run TLS function coverage tests under ASan on Linux`) — addresses #7062. - #7089 (`fix(libSceAgcDriver): normalize reserved bit 30 in guest buffer descriptors`) — addresses #7051.
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!7108
No description provided.