fix(libkernel): fill kern.rng_pseudo and kern.arandom from host OS entropy #5275
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5275"
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 winstrex on 2026-10-13T16:17:08Z.
What
Follow-up to #4200.
kern.rng_pseudoandkern.arandom(MIB {1, 37} and itssysctlbynamename, both added by #3700) were the last guest entropy sources still drawing from astatic std::random_device, one call per output byte. They now fill the buffer withHostEntropy_nid_no_patch(getentropy,rand_son Windows), likearc4random,/dev/randomandsceRandomGetRandomNumbersince #4200.Only the entropy source changes.
kern.rng_pseudostill fills*oldLengthbytes and leaves the length as it was, returnsEPERMfor a write and throws without an output buffer;kern.arandomstill returnsmin(*oldLength, 256)bytes, reports that size for a null buffer and returnsEPERMfor a write. The twodocs/dev/debt/libkernel.mdentries now name host OS entropy instead ofstd::random_device.On the AMD EPYC 9V45 runner measured in #4200, a
std::random_devicecall took about 23.5 µs, so one call per byte cost about 1.5 ms for the 64-byte blocks mbedTLS askskern.rng_pseudofor and 6 ms for a 256-bytekern.arandomread.Tested
Windows 11, WinLibs GCC 15.2.0 r7, Release.
guest_system_configuration(CheckPseudoRandomSysctl,CheckArandomSysctl),guest_posix_random,guest_randomandguest_crtpass.EPERM, the throw, two reads that differ) pass before and after. No test I could write fails without the change on the machines I have.python tools/check_conventions.py --base upstream/mainpasses.build.yml(run 38423102411): Windows passes; Linux passes exceptguest_math, which fails the same way onmain's own Linux runs (for examplea74f2efe8,39890031eand765661581) and does not touch these sysctls.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)Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:30:09Z.
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Pull request closed