fix(libkernel): report kern.proc kinfo_proc as the console's 1,096 bytes #22788
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22788"
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 xXPBSXx on 2026-11-18T09:21:44Z.
What
Makes
kern.proc.pid,kern.proc.pid_tdandkern.proc.procreport the process record,kinfo_proc, with the 1,096 bytes that a PS5 on firmware 11.60 reported to a payload process, where AnyPS5 reported FreeBSD 11 amd64's 1,088 bytes. Four probes on that PS5 only readsysctl; the first comment has the raw output of the two that readkern.proc.pid(first and second probe below), the second comment that of the two that readkern.proc.procandkern.proc.pid_td(third and fourth probe):kern.proc.pid, own pid. The size query with a null buffer returned 0 with a length of 1096 (first probe, line 18; second probe, line 10). A 1096-byte and a 0x448-byte buffer returned 0 with a length of 1096 andki_structsize1096 (second probe, lines 4, 5 and 7);ki_pidequalledgetpid()andki_ppidequalledgetppid()(second probe, line 5). A 1088-byte (0x440) buffer returned -1 with errno 12 (ENOMEM), the length after the call was 1088 and 1088 bytes were changed, so the console copies what fits and then reportsENOMEM(first probe, lines 12 and 15; second probe, line 8); the same holds for 512 bytes (first probe line 16, second probe line 9) and 1 byte (first probe line 17). The pids -1 and 0x7fffffff returned -1 with errno 3 (ESRCH) (first probe, lines 21 and 22; second probe, lines 13 and 14), as the Debt entry says for AnyPS5. The console also answered for the parent pid and pid 1 (second probe, lines 11 and 12; third probe, lines 29 and 30); AnyPS5 answers only for its own pid, which the entry already states, and this change does not touch that.ki_pid(72),ki_ppid(76) andki_comm(447) of FreeBSD 11 amd64'skinfo_procheld, so the 8 extra bytes are at the end of the record. The probes do not say what they contain, and this change fills them with 0 like the rest of the unfilled record.kern.proc.proc. A PS5 payload process listed dozens of processes, each a record of 1,096 bytes: the size query returned 104120 in the third probe (line 4) and 105216 in the fourth (line 4), and the read in the fourth returned a length of 99736 with 91 records, all 91 withki_structsize1096 (line 5; 91 times 1096 is 99736). The number of records differs between the runs, so no count is taken from them, and no pid or name is printed in either probe. AnyPS5 lists one record.kern.proc.pid_td(KERN_PROC_PIDwithKERN_PROC_INC_THREAD). The console returned -1 with errno 2 (ENOENT) for the size query, the read, a read with three helper threads running, and the pids of the parent, 1, 0x7fffffff and -1 (third probe, lines 18 to 24). AnyPS5 returns one record per live guest thread. That difference is not changed here; the entry now says that the console answersENOENT.In
core/libs/prx/libkernel/System/src/SystemConfiguration.cpp(line numbers atmain194964cd3ce, the base of this branch)GuestKinfoProc(:199-218) ended inreserved6[484]with astatic_assertonsizeof == 1088.GuestProcessRecord(:221-228) setsstructSize = sizeof(process), and the three sysctls build their records from it:kern.proc.proc(:514, its size query(EstimatedExtraProcesses + 1) * sizeof(GuestKinfoProc)at:512),kern.proc.pid(:530) andkern.proc.pid_td, withGuestProcessRecord()per thread (:240) and a length ofrecords.size() * sizeof(GuestKinfoProc)(:547).CopyOut(:39-54) already copiesmin(capacity, size)bytes and returns -1 with errno 12 when that is less than the size, which is what the console does, so it is unchanged. The fix isreserved6[484]toreserved6[492]and thestatic_assertto 1096 (2 lines inSystemConfiguration.cpp); the size query,ki_structsizeand the process and thread lists follow from it. The six-record size query ofkern.proc.proc(from #22014) becomes six times 1096.Only
kern.proc.pidwas measured with a buffer of its own size. Forkern.proc.procthe record size is measured, the number of records is not copied, and forkern.proc.pid_tdthe console does not answer, so its 1,096-byte records are not measured. A caller that asks for its own record with a 0x440-byte buffer, as Source Port (PPSA20040) does for the debugger check, now getsENOMEMwith the first 1,088 bytes copied, as on the console; no title was run for this PR.The test,
core/libs/tests/GuestSystemConfiguration.cpp, changes 21 occurrences of 1088 to 1096 (including the six-record size query of #22014) and adds one case: a 1088-byte buffer returns -1 with errno 12, a length of 1088, 1088 bytes copied, the byte after them untouched,ki_structsize1096 and the rightki_pid. The values pinned are the console's from the probes above; the values ofki_flagand of the other unfilled bytes are not pinned.Debt: there is no new fragment file. A second fragment on the same entry would be a fold error, which
tools/check_conventions.pyreports as an error, so the text is edited in the two merged fragments that are not folded yet:docs/dev/debt/changes/fix-libkernel-sysctl-proc-list-size-estimate.md(#22014,kern.proc.proc, 916 to 899 characters) anddocs/dev/debt/changes/fix-libkernel-sysctl-proc-pid-thread-id.md(#21986,kern.proc.pid869 to 997 andkern.proc.pid_td953 to 995 characters, counted without the leading "- "). They are other authors' files, and the change to them is deliberate.kern.proc.procnow says the record is 1,096 bytes and that a PS5 payload process lists dozens of processes of that size, titles not measured;kern.proc.pidsays the record is 1,096 bytes as a firmware 11.60 payload reports it and that here a 1,088-byte buffer getsENOMEMafter a 1,088-byte copy (the console's own result for that buffer is in the raw output, lines 12 and 15 of the first probe, and is not stated in the entry);kern.proc.pid_tdsays the console answersENOENT. All three entries are at most 1000 characters.tools/debt_fold.py --checkreports nothing forkern.proc.Tested
Measured on a PS5 with firmware 11.60 (
kernel_get_fw_version0x11600005), from a homebrew payload process (ps5-payload-sdk v0.45, elfldr). First probe 2026-11-17 at 23:35 UTC, second 2026-11-18 at 00:05 UTC, third 2026-11-18 at 04:36 UTC, fourth 2026-11-18 at 05:05 UTC (the console clock printed 01:17:39, 01:47:32, 06:18:05 and 06:47:41 and runs 1 h 42 min ahead of UTC). A title process may differ. In the first comment, the lines that printki_flagand byte counts of the record (line 14 of the first probe and line 6 of the second) and the value of the first characters ofki_commare removed and replaced by a note; the other lines keep their numbers. The second comment has the two other probes as printed.mainbeforekern.proc.pidsize query, own pid:199-228)kern.proc.pid, 1096-byte and 0x448-byte bufferski_structsize1096 (second probe lines 4, 5, 7)kern.proc.pid, 1088-byte bufferkern.proc.pid, 512-byte and 1-byte buffersCopyOut:39-54)kern.proc.pid, pid -1 and 0x7fffffffkern.proc.pid, parent pid and pid 1kern.proc.proc, record sizekern.proc.pid_td, own pidguest_system_configurationfails without the fix and passes with it, on the samemain194964cd3ce: with the test commit alone (78582bdd191b) it fails on Windows (MinGW-w64 g++ 15.2.0, Release, ninja -j4, exit code 0xc0000409, 0.41 s, run at about 06:25 UTC on 2026-11-18) and with the fix and the Debt commit of the earlier head (cf0beca2c0db) it passes (1 of 1, 0.46 s); the branch heade6fa223cbe0differs from it only in one sentence of a Debt fragment, its code and test trees are the same. On Linux (WSL Ubuntu 24.04, g++ 13.3.0, Release, ninja -j4, run at about 06:30 UTC), withSystemConfiguration.cppatreserved6[484]and the assert at 1088 (sha256 starting70f637117fb3) the test reportsSubprocess aborted(0% passed, 0.04 s) and withreserved6[492]and 1096 (sha256 starting5ebb4b6a104f) it passes (0.03 s, 100%).tools/check_conventions.py --base upstream/mainreports no error and no warning on the branch. Not tested: macOS, the CI runner, a title process (PPSA20040 or another), the number of processes the console lists, the 1,096-byte records ofkern.proc.pid_td, and the contents of the 8 extra bytes.Overlap: the other open pull requests that change the files of this branch (
core/libs/prx/libkernel/System/src/SystemConfiguration.cpp,core/libs/tests/GuestSystemConfiguration.cppand the two fragmentsdocs/dev/debt/changes/fix-libkernel-sysctl-proc-list-size-estimate.mdanddocs/dev/debt/changes/fix-libkernel-sysctl-proc-pid-thread-id.md, which are onmainand not folded yet) or the debt entrieskern.proc.proc,kern.proc.pidandkern.proc.pid_td, found by reading the changed files of all 1761 open pull requests at about 08:32 to 08:54 UTC, by reading what they change indocs/dev/debt/libkernel.mdand the fragments underdocs/dev/debt/changes/forkinfo_procandkern.proc, and by searching their titles and branch names for the same names (one hit, #22483), were checked on 2026-11-18 at about 08:35 UTC againstmain1ccc399b171together with this head (the branch is based on194964cd3ce, an ancestor of it, merges intomainwithout a conflict, andtools/debt_fold.py --checkapplies the two changed fragments together with every other fragment onmainwithout an error), and the two that list one of the code files or name the same sysctls were merged with and without this branch at about 08:56 UTC againstmainb1a1e61f914. No open pull request changes the two fragments or a line of the three entries. #22483 (audit sysctl kern.proc.* process, pathname, env, and vmmap bounds) adds only a test and aCMakeLists.txtline and merges cleanly with and without this branch; its test declares its ownTestKinfoProcwith a size of 1088 bytes and compares lengths with it, so after this change lands its test fails against the 1,096-byte record (or the other way round, this change makes it fail), and whichever lands second has to change that size; this is not aDepends on. #12315 (feat(libSceLibreSsl3): ..., a branch with many unrelated files) conflicts withmainby itself inlibSceLibreSsl3, carries olderkern.proc.proccode and a test that expects a length of 1088, and does not conflict only with this branch. Fifty-nine pull requests list one of the files ordocs/dev/debt/libkernel.md, most of them for other entries; none of the others touches these sysctls. The merge withmainwas not built or run; the runs below are on the base194964cd3ce.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 PrivacyOnion on 2026-11-18T09:23:34Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
e6fa223cbe:tools/check_conventions.pypassed.guest_system_configuration_testsbuilt cleanly.guest_system_configuration):core/libs/prx/libkernel/System/src/SystemConfiguration.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T03:41:56Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected implementation and test updates support the reported 1,096-byte process record behavior.
What I ran
e6fa223cbe0858368e9b515c76bc88a401667109usingrepo_read.pyto inspect the prepared review artifacts and targeted source ranges.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No build or test was run independently. The PR description states that the test passed on Windows and Linux and that the convention check passed. The changed code, test, and debt fragments were read; no changed files were excluded. Console behavior and the PR's reported measurements were not independently verified.
To get this to a good state
Nothing is required.