fix(libkernel): return kern.rng_pseudo in 64-byte blocks as measured on a PS5 #7542
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7542"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by ionut27001 on 2026-10-18T12:59:21Z.
What
sysctlbyname("kern.rng_pseudo")now returns its random bytes in blocks of 64, sized the way a payload process on a PS5 (firmware 12.70) sees them. The 64 random bytes are drawn only for a read that passes both a buffer and a length.mainbefore this PRENOMEM; that many bytes written, length unchangedENOMEM, nothing writtenerrnoon successEach such read takes a new 64-byte block from the host's
std::random_device; a write returnsEPERMbefore any byte is drawn. After eight consecutive 64-byte reads on the console, the eight buffers were pairwise different (p24; their return values were not logged and the buffers were not prefilled), and in p16 two reads both returned 0 with length 64 and differed. The block goes out throughCopyOut, so every case in the table follows from it. A write still returnsEPERM; the probes never write a sysctl, so the console's answer to a write is unknown.Changes in
docs/dev/debt/libkernel.md:sysctlnametomibanswers the same way, while heresysctlnametomibfor the name andsysctl{1, 50} still throw.How the console was measured
resolvelines of p10 and p16 show that theirsysctlbyname(and p16'ssysctlandsysctlnametomib) are the oneslibkernel_sys.sprxexports; p13 resolvessysctlandsysctlnametomib, and p24 prints no resolve lines. All probes linksysctlbynamethe same way.last_changedand thechanged_in_*counts were prefilled with0xAA.last_changedis one past the last byte that changed.changed_in_askedcounts the changed bytes among the requested ones, andchanged_in_64among the first 64.errno: preset to 77 where the line sayserrno=77orerrno_after=77.Console output (excerpt, lines copied unchanged)
The
pNN:prefix names the probe; the rest of each line is copied unchanged.Overlaps:
sysconfdebt line, which sits right below thekern.rng_pseudoline, so whichever lands second keeps both lines. #6044 movesGuestSystemConfiguration.cpp, so whichever lands second only has to change the path when rebasing.sysctlbyname_nid_postfix,GuestSystemConfiguration.cppand the debt lines belowsysconf. The two merge cleanly in either order.sysctlMIB {1, 50} and rewrites the samekern.rng_pseudodebt line. Whichever lands second merges the two texts: the name path from this PR and the MIB path from #7554, without this PR's clause thatsysctlnametomibandsysctl{1, 50} throw.Tested
Build: Windows 11 x86-64, full build with WinLibs MinGW-w64 GCC 15.2.0 (posix-seh, ucrt, r7) and
-DBUILD_TESTING=ON.Rebase (not re-tested): after #6833 landed, this branch was rebased onto
mainbbb45463c. The only conflict was indocs/dev/debt/libkernel.md, where #6833 changed thesysconfline right after this PR'skern.rng_pseudoline; the resolution keeps both. The code and test changes are the same as before the rebase, and the tests above were not run again on the new base.Tests: with this branch on top of
main9f25d0bf5b,guest_system_configurationand the otherguest_*tests pass: 464 of 465 pass andguest_video_out_wqhd_detection_no_vulkanis skipped on this machine. The branch was then rebased ontomain5bf2e139efwithout conflicts, since upstream changed none of its code or test files, andguest_system_configurationpasses there too.Old code, new test: with
SystemConfiguration.cppreverted tomainand the new test kept,guest_system_configurationaborts.Console: behaviour measured on a PS5 (firmware 12.70), as described above.
Not tested: Linux, and no title. The only caller the debt entry names, mbedTLS in the ProsperoLight boilerplate, asks for 64-byte blocks, and a 64-byte request still gets 64 bytes.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T13:33:26Z.
I'm preparing a separate PR for measured kern.rng_pseudo MIB {1,50} support and its sysctlnametomib mapping. The overlap checker flags nearby insertion points in SystemConfiguration.cpp and GuestSystemConfiguration.cpp; the behavior is separate, but rebasing may need small conflict resolutions. Which PR should land first, or are you comfortable with this one landing first?
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T13:36:50Z.
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.
main)docs/dev/debt/libkernel.mdL19Some 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.
docs/dev/debt/libkernel.mdcore/libs/tests/GuestSystemConfiguration.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T13:54:08Z.
Update: the separate numeric
kern.rng_pseudoMIB PR is now open as #7554. It handles the measured {1,50} access shape, distinct from this PR’s 64-byte name-query block behavior. The changes are independent; whichever lands second may need a small rebase conflict resolution.Imported from boykopovar/AnyPS5. Originally posted by ionut27001 on 2026-10-18T14:37:54Z.
Either order is fine. The real conflict is the
kern.rng_pseudodebt line, which both PRs rewrite: this one describes the 64-bytesysctlbynamebehaviour and sayssysctlnametomibandsysctl{1, 50} throw, while #7554 keeps the oldsysctlbynametext. Whichever lands second should merge them (name path from here, MIB path from #7554, without the "throw" clause). I'll do it on my side if #7554 lands first. One note on #7554, since it cites these logs: the probes only called the two-word MIB {1, 50}, soENOTDIRfor a trailing component was not measured.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T14:46:08Z.
Thanks for catching the probe scope. I corrected #7554’s description: it now attributes the trailing-component
ENOTDIRresult to current generic leaf-MIB handling and explicitly says that longer MIB was not measured on PS5. Your note about resolving the shared debt line after merge still applies.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T10:26:07Z.
Checked
CopyOutagainst each row of the console table (size query, 64+ bytes, short buffer, null length, null/null, errno kept), the test (fails onmain: whole buffer filled / throws) and the debt entry; merged.