fix(libkernel): resolve sysctl top-level names and fail absent top-level MIBs with ENOENT as measured on a PS5 #11170
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11170"
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 orezraey on 2026-10-25T20:27:52Z.
What
This aligns the
sysctlcalls with a retail PS5 (firmware 13.60) for absent top-level nodes and top-level names. Measured with a homebrew probe from a payload process; the source and console log are in this gist (pmibunk).On the console:
{99, 1}, returns -1 withENOENTand leaves the buffer and length alone. So do unknown MIBs under known nodes:{1, 9999},{6, 9999},{0, 9999},{1, 14, 9999, pid}and 24 levels starting with{1, 9999}.sysctlnametomib("kern")and("kern.")return 0 with the single level{1}, whilesysctlbynamefails both withEINVAL(a one-level MIB).ENAMETOOLONG(63) from both calls. HeresysctlbynamegaveENOENT.Changes:
sysctl. A MIB whose top-level number is negative or from 10 to 255 now getsENOENT, with the buffer and length untouched; a write to one still throws. FreeBSD 11 numbers its static top-level nodes 0 to 9 and its dynamic ones from 256 (CTL_AUTO_START), so 10 to 255 cannot exist there.ENOENTthe console gave for{1, 9999}and the others. A MIB that exists on the console but is not implemented here would otherwise fail silently. The debt entry records the measuredENOENTcases.sysctlnametomib. It maps the ten FreeBSD top-level names (sysctl,kern,vm,vfs,net,debug,hw,machdep,user,p1003_1b) to one level. It also drops one trailing dot from any name, as FreeBSD'sname2oiddoes.sysctlbyname. It fails a name of 1024 bytes or more withENAMETOOLONGfirst, drops one trailing dot, and fails a top-level name withEINVAL, as FreeBSD's libc does when it passes the one-level MIB tosysctl.Before and after
sysctl{99, 1}(absent top-level node)ENOENT, buffer untouchedENOENT, buffer untouchedsysctlnametomib("kern")and("kern."){1}ENOENT{1}sysctlbyname("kern")EINVALENOENTEINVALENAMETOOLONGENOENTfromsysctlbynameENAMETOOLONG{1, 9999}and other unknown MIBs under a known nodeENOENTTested
guest_system_configurationpasses 3 times out of 3 on Windows 11 (WinLibs GCC 15.2) and 3 times out of 3 on Linux (WSL, GCC 16.2). The newCheckUnknownRootsAndTopLevelNamescovers:ENOENTwith the buffer and length untouched (writes below them and reads below roots of 256 or more still throw in the code, but the test does not require it, since those MIB forms are only unimplemented);hw.ncpu.,kern..,.,kern.anyps5.xandkernel;tools/check_conventions.pypasses. Head82f9806500onmain74a55da254.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)hw.pagesizedebt entry right after the one this PR rewrites); merge order onlyImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T20:33:05Z.
Review: COMMENTED
Reviewed exact head
65d87b4ecb25878b36a2368bf42850a93e96ffd3.I checked the probe source/log and the error paths. The PS5 log directly records
{99,1}returningENOENTwithout changing output/length, unknown children under known roots, top-levelkern/kern.name conversion, and the measured length/name cases. The new early return is limited to absent static roots and preserves the existing exception for unimplemented MIBs at256+; the existing known-name paths run first. The name normalization removes exactly one trailing dot, so repeated dots remain invalid.Evidence boundary: the supplied console log probes root 99; the behavior for negative roots and the whole 10–255 range is inferred from the FreeBSD static-root / dynamic-root numbering convention and covered by the new local tests, not independently measured on the PS5.
Checks I ran: local conventions pass;
git diff --check upstream/main...HEADpasses; the merge preview against currentmainis clean. The Windowsguest_system_configurationresults and console measurements in the PR are author-reported. Hosted product jobs are skipped for this PR, and I could not reproduce a local build in this checkout.