fix(libkernel): reject empty sceKernelOpen paths #3428

Merged
MarcZX10 merged 1 commit from upstream-pr/3428 into main 2026-10-11 11:55:48 +00:00
MarcZX10 commented 2026-10-11 10:22:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T10:22:28Z.


Related to #3308.

What

Cyberpunk 2077 (PPSA04029 v02.120.000, Linux) reaches sceKernelOpen("") during its launcher stage. On pre-fix main, path resolution turns the empty string into the guest root directory, so the open succeeds and the following read throws. Return SCE_KERNEL_ERROR_ENOENT for an empty path before resolving it, matching POSIX open("") behavior. Add a direct sceKernelOpen regression check; the existing open wrappers already check the same error.

Observed stop on pre-fix main:

what(): sceKernelRead: read failed, fd=6, errno=21

The issue reporter's controlled probe on the same title continued past this stop when sceKernelOpen("") returned ENOENT. This PR does not claim to resolve the title's later stops.

Tested

  • Linux, GCC 12.2, Release: built guest_filesystem_tests; guest_filesystem passed 1/1 on the rebased branch.
  • python3 tools/check_conventions.py --base upstream/main — passed.
  • git diff --check — passed.
  • Cyberpunk was not run locally.

Checklist

  • Based on current main (9a9bd3fb); no open PR implements this behavior
  • 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 in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behavior, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4818359309 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3428). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T10:22:28Z. --- Related to #3308. ### What Cyberpunk 2077 (PPSA04029 v02.120.000, Linux) reaches `sceKernelOpen("")` during its launcher stage. On pre-fix `main`, path resolution turns the empty string into the guest root directory, so the open succeeds and the following read throws. Return `SCE_KERNEL_ERROR_ENOENT` for an empty path before resolving it, matching POSIX `open("")` behavior. Add a direct `sceKernelOpen` regression check; the existing `open` wrappers already check the same error. **Observed stop on pre-fix main:** ```text what(): sceKernelRead: read failed, fd=6, errno=21 ``` The issue reporter's controlled probe on the same title continued past this stop when `sceKernelOpen("")` returned `ENOENT`. This PR does not claim to resolve the title's later stops. ### Tested - Linux, GCC 12.2, Release: built `guest_filesystem_tests`; `guest_filesystem` passed 1/1 on the rebased branch. - `python3 tools/check_conventions.py --base upstream/main` — passed. - `git diff --check` — passed. - Cyberpunk was not run locally. ### Checklist - [x] Based on current `main` (`9a9bd3fb`); no open PR implements this behavior - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behavior, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
adriadam10 commented 2026-10-11 10:47:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T10:47:32Z.


Checked on Linux: guest_filesystem passes with the change and fails without it (the new sceKernelOpen("", 0, 0) row), no overlap with other open PRs. The empty-path check matches FreeBSD namei (sys/kern/vfs_lookup.c, "Don't allow empty pathnames"); merging.

The same hole exists in the other path-taking calls (sceKernelStat, Rmdir, Rename, Chmod...), as noted in #3308; that is a separate topic for a follow-up PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108222172 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3428#issuecomment-6108222172). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T10:47:32Z. --- Checked on Linux: `guest_filesystem` passes with the change and fails without it (the new `sceKernelOpen("", 0, 0)` row), no overlap with other open PRs. The empty-path check matches FreeBSD `namei` (`sys/kern/vfs_lookup.c`, "Don't allow empty pathnames"); merging. The same hole exists in the other path-taking calls (`sceKernelStat`, `Rmdir`, `Rename`, `Chmod`...), as noted in #3308; that is a separate topic for a follow-up PR.
MarcZX10 commented 2026-10-11 11:02:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T11:02:21Z.


I opened the requested separate follow-up in #3465 for the remaining kernel path-taking calls. It adds empty-path checks and guest_filesystem regression coverage; it is based on current main and has no dependency on this PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108336460 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3428#issuecomment-6108336460). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T11:02:21Z. --- I opened the requested separate follow-up in #3465 for the remaining kernel path-taking calls. It adds empty-path checks and `guest_filesystem` regression coverage; it is based on current `main` and has no dependency on this PR.
adriadam10 commented 2026-10-11 11:55:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T11:55:46Z.


Checked: guest_filesystem passes with the change and fails without it (the new sceKernelOpen("", 0, 0) row); scoped build + ctest green (111/111). The empty-path check matches FreeBSD namei ("Don't allow empty pathnames"), and nullptr keeps its previous path. Merging; the remaining path-taking calls are covered by #3465.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108757838 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3428#issuecomment-6108757838). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T11:55:46Z. --- Checked: `guest_filesystem` passes with the change and fails without it (the new `sceKernelOpen("", 0, 0)` row); scoped build + ctest green (111/111). The empty-path check matches FreeBSD `namei` ("Don't allow empty pathnames"), and `nullptr` keeps its previous path. Merging; the remaining path-taking calls are covered by #3465.
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!3428
No description provided.