fix(libkernel): return EFAULT from sceKernelTruncate and sceKernelUtimes for a null path #7110

Closed
pushkarreddyy wants to merge 1 commit from upstream-pr/7110 into main
pushkarreddyy commented 2026-10-17 12:04:20 +00:00 (Migrated from github.com)

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


What

sceKernelTruncate and sceKernelUtimes threw std::invalid_argument when called with a null path. In FreeBSD 11, sys_truncate and sys_utimes fail with EFAULT (0x8002000e in PS5 errno) when copying the path from user space fails.

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 sceKernelTruncate and sceKernelUtimes fail with 0x8002000e on a null path 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:4899898363 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7110). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-17T12:04:20Z. --- ### What `sceKernelTruncate` and `sceKernelUtimes` threw `std::invalid_argument` when called with a null path. In FreeBSD 11, [`sys_truncate`](https://github.com/freebsd/freebsd-src/blob/releng/11.0/sys/kern/vfs_syscalls.c#L3403) and [`sys_utimes`](https://github.com/freebsd/freebsd-src/blob/releng/11.0/sys/kern/vfs_syscalls.c#L3308) fail with `EFAULT` (`0x8002000e` in PS5 errno) when copying the path from user space fails. 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 `sceKernelTruncate` and `sceKernelUtimes` fail with `0x8002000e` on a null path 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
oneandonlydean commented 2026-10-17 12:10:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T12:10:43Z.


Thanks, @pushkarreddyy. This and #7113 both look right: null path -> EFAULT, same pattern as #7108.

One practical problem: #7108, #7110 and #7113 all add lines at the same two places in core/libs/tests/GuestPosixScalarIo.cpp. Each merges cleanly into main on its own, but as soon as one lands the other two conflict.

Plan: #7108 merges first. After that, could you fold #7110 and #7113 into one PR rebased on main? While you're there, sceKernelRename (Stdio.cpp:1273) still throws on a null path and fits the same change. We'd then run CI once on the combined head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6233724628 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7110#issuecomment-6233724628). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T12:10:43Z. --- Thanks, @pushkarreddyy. This and #7113 both look right: null path -> EFAULT, same pattern as #7108. One practical problem: #7108, #7110 and #7113 all add lines at the same two places in `core/libs/tests/GuestPosixScalarIo.cpp`. Each merges cleanly into main on its own, but as soon as one lands the other two conflict. Plan: #7108 merges first. After that, could you fold #7110 and #7113 into one PR rebased on main? While you're there, `sceKernelRename` (`Stdio.cpp:1273`) still throws on a null path and fits the same change. We'd then run CI once on the combined head.
github-actions[bot] commented 2026-10-17 12:17:00 +00:00 (Migrated from github.com)

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


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/Stdio.cpp
PR 6044 core/libs/tests/GuestPosixScalarIo.cpp
PR 6222 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 6287 core/libs/prx/libkernel/File/src/Stdio.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6233779028 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7110#issuecomment-6233779028). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-17T12:17:00Z. --- <!-- 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/Stdio.cpp` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestPosixScalarIo.cpp` | | [PR 6222](https://www.github.com/boykopovar/AnyPS5/pull/6222) | `core/libs/prx/libkernel/File/src/Stdio.cpp` | | [PR 6287](https://www.github.com/boykopovar/AnyPS5/pull/6287) | `core/libs/prx/libkernel/File/src/Stdio.cpp` |
pushkarreddyy commented 2026-10-17 12:21:34 +00:00 (Migrated from github.com)

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


Thanks @oneandonlydean! That plan makes total sense.

I have rebased on latest main and prepared the combined branch holding the full remaining set (sceKernelTruncate, sceKernelUtimes, sceKernelMkdir, sceKernelRmdir, and sceKernelRename).

Whenever #7108 merges into main, I will immediately update this PR (#7110) with the folded commits and close #7113 and #7114 so CI runs cleanly once on the combined head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6233818911 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7110#issuecomment-6233818911). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-17T12:21:34Z. --- Thanks @oneandonlydean! That plan makes total sense. I have rebased on latest main and prepared the combined branch holding the full remaining set (sceKernelTruncate, sceKernelUtimes, sceKernelMkdir, sceKernelRmdir, and sceKernelRename). Whenever #7108 merges into main, I will immediately update this PR (#7110) with the folded commits and close #7113 and #7114 so CI runs cleanly once on the combined head.
pushkarreddyy commented 2026-10-17 14:06:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-17T14:06:11Z.


Closing in favor of consolidated PR #7114 following @oneandonlydean's directive (folding #7110, #7113, and #7114 together on top of #7108).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6234857892 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7110#issuecomment-6234857892). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-17T14:06:11Z. --- Closing in favor of consolidated PR #7114 following @oneandonlydean's directive (folding #7110, #7113, and #7114 together on top of #7108).

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