Repository navigation
fix(libkernel): return kern.rng_pseudo in 64-byte blocks as measured on a PS5 - #7542
Conversation
|
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? |
|
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.
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.
|
|
Update: the separate numeric |
|
Either order is fine. The real conflict is the |
|
Thanks for catching the probe scope. I corrected #7554’s description: it now attributes the trailing-component |
…on a PS5
In a payload process on a PS5 (firmware 12.70),
sysctlbyname("kern.rng_pseudo") answers a size query with 64 and gives
at most 64 bytes per call, up to a 65536-byte buffer. A buffer smaller
than 64 bytes gets as many bytes as its length and a null length gets
none, both with -1 and ENOMEM; a null buffer with a null length returns
0, and errno is kept when the call succeeds. Here the whole buffer was
filled, a size query threw and the length was never changed. The 64
random bytes are now drawn only for a read that passes both a buffer
and a length.
AI-assisted: yes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6df22de to
dca67ae
Compare
|
Checked |
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. test: organize library tests and label CTest suites #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 fix(libkernel): support kern.rng_pseudo MIB access #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
mainbbb4546. 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
main9f25d0b,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 ontomain5bf2e13 without 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