feat(libkernel): implement sceKernelGetFsSandboxRandomWord #1807

Merged
SleglJan merged 1 commit from upstream-pr/1807 into main 2026-10-09 21:52:41 +00:00
SleglJan commented 2026-10-08 19:54:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-08T19:54:29Z.


What

Adds sceKernelGetFsSandboxRandomWord to libkernel, in a new System/src/Sandbox.cpp. On the console a title's sandbox root holds app0 and a directory with a random-looking name under which system files are exposed; the function returns that name, and the open-source SDKs splice it into paths: /<name>/common/cert/CA_LIST.cer (ProsperoEden), /<name>/common/lib/libc.sprx (tiny-ps4-shell), /<name>/common/lib/mscorlib.dll (ps4-hen-plugins). The kernel keeps the name per process and randomized_path (syscall 602) reads it back, as obliteration implements it, with /system/common/lib mounted at <name>/common/lib.

  • The name is fixed, gkbHtXc3Wq, so a path built from it is the same across runs. It is recorded in TechnicalDebt: nothing is mounted under the name here, so /gkbHtXc3Wq/common/... resolves under the guest root like any other path and does not exist.
  • The pointer is to static storage and the same on every call and every thread; the function cannot fail.

Of the 34 relinked titles in the homebrew catalog (#1578), 12 import the function and 5 stop at it on main b858fdc4: each dies in the loader with app.elf: symbol lookup error: app.elf: undefined symbol: JGfTMBOdUJo. They are PPSA17641 SymphonyStation5, PPSA74126 Stremio Plus, PPSA97510 PSXS5, PPSA99009 ProsperoLichess and PPSA99082 OpenNOW PS5 - Prototype, which makes it the most common next stop in the catalog. With this change each of them reaches its next missing import: sceVideoOutGetResolutionStatus (#1714), socketpair (#1711), geteuid (#1650), geteuid (#1650) and sysctlbyname (#1685).

Overlap: none by tools/pr_overlap.py against the open pull requests. #1748, #1650 and #1675 change System/src/Process.cpp, which this does not touch; the source line goes after Process.cpp in libkernel/CMakeLists.txt, the test block after guest_file_vector, and the TechnicalDebt entry after the sceKernelPread one, clear of #1802's rewrite of the sceKernelRaiseException entries.

Tested

  • Linux (CachyOS, kernel 7.2.9, GCC 16.2.1), full build with BUILD_TESTING=ON and ANYPS5_ENABLE_SPIRV_TOOLS=ON on this branch (based on main b858fdc4): ctest --repeat until-fail:3 487/487; tools/check_test_registration.py and tools/check_conventions.py --base upstream/main pass.
  • New guest_sandbox_random_word test: a non-null, non-empty alphanumeric name, the same pointer on a second call and from another thread, and open of /<name>/common/lib/libc.sprx failing with ENOENT. Written before the implementation; it failed on the unresolved export and passes with it.
  • The patched libkernel.prx exports the NID (JGfTMBOdUJo).
  • The five titles above, relinked on main b858fdc4 and run for 8 s each in a bubblewrap sandbox (Linux, RTX 3080): every one stops in the host loader on undefined symbol: JGfTMBOdUJo; with this branch's libkernel.prx the same runs stop on the next import listed above.
  • tools/import_audit.py on four of the 12 catalog titles, absent imports on main b858fdc4 → this branch: PPSA17641 SymphonyStation5 35 → 34, PPSA97510 PSXS5 72 → 71, PPSA99009 ProsperoLichess 37 → 36, PPSA99082 OpenNOW PS5 - Prototype 36 → 35; the one that disappears is this function each time. No title was run, since each still has other absent imports, listed in #1578.
  • Windows: the same Build workflow run on this commit in the fork's Actions (merged onto main b858fdc4), run 37833619159: guest_sandbox_random_word passes its three repeats, full suite 478/478 on Windows and 487/487 on Linux.

Checklist

  • Based on current main; no other open PR implements the same functions
  • 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 (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4792064797 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1807). Originally posted by [SleglJan](https://github.com/SleglJan) on 2026-10-08T19:54:29Z. --- ### What Adds `sceKernelGetFsSandboxRandomWord` to libkernel, in a new `System/src/Sandbox.cpp`. On the console a title's sandbox root holds `app0` and a directory with a random-looking name under which system files are exposed; the function returns that name, and the open-source SDKs splice it into paths: `/<name>/common/cert/CA_LIST.cer` ([ProsperoEden](https://github.com/blackbearreloaded/ProsperoEden/blob/main/headless/update_check/console_curl.c)), `/<name>/common/lib/libc.sprx` ([tiny-ps4-shell](https://github.com/john-tornblom/tiny-ps4-shell/blob/master/kern_orbis.c)), `/<name>/common/lib/mscorlib.dll` ([ps4-hen-plugins](https://github.com/Scene-Collective/ps4-hen-plugins/blob/main/plugin_mono/source/mono.c)). The kernel keeps the name per process and `randomized_path` (syscall 602) reads it back, as [obliteration](https://github.com/obhq/obliteration/blob/main/legacy/src/process/mod.rs) implements it, with `/system/common/lib` mounted at `<name>/common/lib`. - The name is fixed, `gkbHtXc3Wq`, so a path built from it is the same across runs. It is recorded in TechnicalDebt: nothing is mounted under the name here, so `/gkbHtXc3Wq/common/...` resolves under the guest root like any other path and does not exist. - The pointer is to static storage and the same on every call and every thread; the function cannot fail. Of the 34 relinked titles in the homebrew catalog (#1578), 12 import the function and 5 stop at it on `main` b858fdc4: each dies in the loader with `app.elf: symbol lookup error: app.elf: undefined symbol: JGfTMBOdUJo`. They are PPSA17641 SymphonyStation5, PPSA74126 Stremio Plus, PPSA97510 PSXS5, PPSA99009 ProsperoLichess and PPSA99082 OpenNOW PS5 - Prototype, which makes it the most common next stop in the catalog. With this change each of them reaches its next missing import: `sceVideoOutGetResolutionStatus` (#1714), `socketpair` (#1711), `geteuid` (#1650), `geteuid` (#1650) and `sysctlbyname` (#1685). Overlap: none by `tools/pr_overlap.py` against the open pull requests. #1748, #1650 and #1675 change `System/src/Process.cpp`, which this does not touch; the source line goes after `Process.cpp` in `libkernel/CMakeLists.txt`, the test block after `guest_file_vector`, and the TechnicalDebt entry after the `sceKernelPread` one, clear of #1802's rewrite of the `sceKernelRaiseException` entries. ### Tested - Linux (CachyOS, kernel 7.2.9, GCC 16.2.1), full build with `BUILD_TESTING=ON` and `ANYPS5_ENABLE_SPIRV_TOOLS=ON` on this branch (based on `main` b858fdc4): `ctest --repeat until-fail:3` 487/487; `tools/check_test_registration.py` and `tools/check_conventions.py --base upstream/main` pass. - New `guest_sandbox_random_word` test: a non-null, non-empty alphanumeric name, the same pointer on a second call and from another thread, and `open` of `/<name>/common/lib/libc.sprx` failing with `ENOENT`. Written before the implementation; it failed on the unresolved export and passes with it. - The patched `libkernel.prx` exports the NID (`JGfTMBOdUJo`). - The five titles above, relinked on `main` b858fdc4 and run for 8 s each in a bubblewrap sandbox (Linux, RTX 3080): every one stops in the host loader on `undefined symbol: JGfTMBOdUJo`; with this branch's `libkernel.prx` the same runs stop on the next import listed above. - `tools/import_audit.py` on four of the 12 catalog titles, absent imports on `main` b858fdc4 → this branch: PPSA17641 SymphonyStation5 35 → 34, PPSA97510 PSXS5 72 → 71, PPSA99009 ProsperoLichess 37 → 36, PPSA99082 OpenNOW PS5 - Prototype 36 → 35; the one that disappears is this function each time. No title was run, since each still has other absent imports, listed in #1578. - Windows: the same Build workflow run on this commit in the fork's Actions (merged onto `main` b858fdc4), [run 37833619159](https://github.com/SleglJan/AnyPS5/actions/runs/37833619159): `guest_sandbox_random_word` passes its three repeats, full suite 478/478 on Windows and 487/487 on Linux. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [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 (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-09 05:32:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T05:32:42Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#2029 docs/dev/TechnicalDebt.md L252
#2170 core/libs/prx/libkernel/CMakeLists.txt L483
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6074959121 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1807#issuecomment-6074959121). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T05:32:42Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #2029 | `docs/dev/TechnicalDebt.md` [L252](https://github.com/boykopovar/AnyPS5/blob/d70b89989473ba1f6ae13e44e079e67f1f8a44b0/docs/dev/TechnicalDebt.md#L252) | | | | #2170 | `core/libs/prx/libkernel/CMakeLists.txt` [L483](https://github.com/boykopovar/AnyPS5/blob/d70b89989473ba1f6ae13e44e079e67f1f8a44b0/core/libs/prx/libkernel/CMakeLists.txt#L483) | | |
github-actions[bot] commented 2026-10-09 08:31:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T08:31:50Z.


Progress report (4b6ab6b → 7785933)

➖ System libraries: 84.76% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel sceKernelGetFsSandboxRandomWord
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6077374066 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1807#issuecomment-6077374066). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T08:31:50Z. --- <!-- progress-report --> ### Progress report (4b6ab6b → 7785933) ➖ **System libraries**: 84.76% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `sceKernelGetFsSandboxRandomWord` | </details>
popcoder565 commented 2026-10-09 10:04:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T10:04:04Z.


First Windows run, since the description says it wasn't tested on Windows.

Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Merged onto main b7218b3c together with nine other small libc/libkernel PRs: #1975, #1976, #1977, #1859, #1685, #1676, #1675, #1641, #1656.

  • guest_sandbox_random_word passes.
  • Full ctest: 510/510 (one GPU test skipped for a device limit).

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078730768 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1807#issuecomment-6078730768). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T10:04:04Z. --- First Windows run, since the description says it wasn't tested on Windows. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Merged onto `main` b7218b3c together with nine other small libc/libkernel PRs: #1975, #1976, #1977, #1859, #1685, #1676, #1675, #1641, #1656. - `guest_sandbox_random_word` passes. - Full ctest: 510/510 (one GPU test skipped for a device limit). _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
adriadam10 commented 2026-10-09 21:52:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T21:52:38Z.


Checked: build + full ctest (524/524) on top of current main, guest_sandbox_random_word passes and the build fails without the change; CI green on the head; no overlap with open PRs. The fixed name is unverified on a console and is recorded in TechnicalDebt.md (shadPS4 also returns a fixed string). Windows run by @popcoder565 confirms the test there. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6089873625 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1807#issuecomment-6089873625). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T21:52:38Z. --- Checked: build + full ctest (524/524) on top of current `main`, `guest_sandbox_random_word` passes and the build fails without the change; CI green on the head; no overlap with open PRs. The fixed name is unverified on a console and is recorded in `TechnicalDebt.md` (shadPS4 also returns a fixed string). Windows run by @popcoder565 confirms the test there. Merging.
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!1807
No description provided.