feat(libkernel): support kern.rng_pseudo in sysctlbyname #3218

Merged
babyhuey merged 1 commit from upstream-pr/3218 into main 2026-10-11 07:57:12 +00:00
babyhuey commented 2026-10-11 01:53:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T01:53:06Z.


What

sysctlbyname answers kern.rng_pseudo by filling the caller's whole buffer with bytes from the host's std::random_device, leaving the length as passed. A write returns -1 with EPERM, like the other names, and a call without an output buffer throws, since what the console reports for a size query is unknown. TechnicalDebt (Unknown function info) records that the console's generator and per-call maximum are unknown.

The caller is mbedTLS's mbedtls_hardware_poll in the catalog's ProsperoLight boilerplate (platform/ps5/ps5_entropy.c), which asks for 64-byte blocks and fails if fewer come back. Four catalog eboots contain the name: Steam Remote Play (PPSA99350), ProsperoLight (PPSA99002), ProsperoLichess (PPSA99009) and OpenNOW (PPSA99082). The last three stop earlier on main (_umtx_op, #1482, and pthread_set_name_np, #3031).

Steam Remote Play stops here on main b6f649d9 (catalog build, eboot.bin and sce_module/libc.prx unwrapped as #2605 requires; tracked in #1578):

  • Linux: terminate called after throwing an instance of 'std::runtime_error' with what(): sysctlbyname_nid_postfix: unsupported name kern.rng_pseudo, right after it opens identity.bin
  • Windows: the same exception ([libc] unhandled exception 'St13runtime_error', unsupported name kern.rng_pseudo)
  • with this PR, Linux: it creates its identity file, passes its crypto self-test and reaches state: LOOKING FOR A PC RUNNING STEAM, then stops at window creation because the Docker run has no Vulkan surface
  • with this PR, Windows: it opens its window and shows the discovery screen ("LOOKING FOR A PC RUNNING STEAM") at about 60 FPS, still running after 60 s

Tested

Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release: guest_system_configuration passes 5/5 (--repeat until-fail:5). The new cases read two 64-byte blocks and check the length and that they differ, that errno is untouched, that a write fails with EPERM, and that a call without a buffer throws. check_conventions.py passes.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4815876157 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3218). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-11T01:53:06Z. --- ### What `sysctlbyname` answers `kern.rng_pseudo` by filling the caller's whole buffer with bytes from the host's `std::random_device`, leaving the length as passed. A write returns -1 with `EPERM`, like the other names, and a call without an output buffer throws, since what the console reports for a size query is unknown. TechnicalDebt (Unknown function info) records that the console's generator and per-call maximum are unknown. The caller is mbedTLS's `mbedtls_hardware_poll` in the catalog's ProsperoLight boilerplate (`platform/ps5/ps5_entropy.c`), which asks for 64-byte blocks and fails if fewer come back. Four catalog eboots contain the name: Steam Remote Play (PPSA99350), ProsperoLight (PPSA99002), ProsperoLichess (PPSA99009) and OpenNOW (PPSA99082). The last three stop earlier on `main` (`_umtx_op`, #1482, and `pthread_set_name_np`, #3031). Steam Remote Play stops here on `main` b6f649d9 (catalog build, `eboot.bin` and `sce_module/libc.prx` unwrapped as #2605 requires; tracked in #1578): - Linux: `terminate called after throwing an instance of 'std::runtime_error'` with `what(): sysctlbyname_nid_postfix: unsupported name kern.rng_pseudo`, right after it opens `identity.bin` - Windows: the same exception (`[libc] unhandled exception 'St13runtime_error'`, `unsupported name kern.rng_pseudo`) - with this PR, Linux: it creates its identity file, passes its crypto self-test and reaches `state: LOOKING FOR A PC RUNNING STEAM`, then stops at window creation because the Docker run has no Vulkan surface - with this PR, Windows: it opens its window and shows the discovery screen ("LOOKING FOR A PC RUNNING STEAM") at about 60 FPS, still running after 60 s ### Tested Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release: `guest_system_configuration` passes 5/5 (`--repeat until-fail:5`). The new cases read two 64-byte blocks and check the length and that they differ, that `errno` is untouched, that a write fails with `EPERM`, and that a call without a buffer throws. `check_conventions.py` passes. ### 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
oneandonlydean commented 2026-10-11 05:05:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T05:05:48Z.


Please rebase this onto main without #2902. That one is waiting on a decision about the version value, and this change doesn't need it; the two only touch the same place in sysctlbyname.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6105683168 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3218#issuecomment-6105683168). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T05:05:48Z. --- Please rebase this onto `main` without #2902. That one is waiting on a decision about the version value, and this change doesn't need it; the two only touch the same place in `sysctlbyname`.
babyhuey commented 2026-10-11 05:35:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T05:35:03Z.


Rebased onto main f5c0fe00 without #2902 (c66d38c5, one commit). guest_system_configuration passes 5/5 on Linux, and Steam Remote Play still gets to LOOKING FOR A PC RUNNING STEAM without kern.sdk_version, so it never asks for that name. I updated the description.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6105879247 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3218#issuecomment-6105879247). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-11T05:35:03Z. --- Rebased onto `main` f5c0fe00 without #2902 (c66d38c5, one commit). `guest_system_configuration` passes 5/5 on Linux, and Steam Remote Play still gets to `LOOKING FOR A PC RUNNING STEAM` without `kern.sdk_version`, so it never asks for that name. I updated the description.
adriadam10 commented 2026-10-11 07:55:11 +00:00 (Migrated from github.com)

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


Rebased onto current main (conflicts with the new sceKernelGetSystemSwVersion check and its TechnicalDebt line; kept both sides, no logic change). Build and libkernel/libs ctest pass on Linux, including guest_system_configuration; the new cases fail without the change. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106881201 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3218#issuecomment-6106881201). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T07:55:11Z. --- Rebased onto current `main` (conflicts with the new `sceKernelGetSystemSwVersion` check and its TechnicalDebt line; kept both sides, no logic change). Build and libkernel/libs ctest pass on Linux, including `guest_system_configuration`; the new cases fail without the change. Merging once CI is green.
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!3218
No description provided.