fix(libkernel): resolve kern.proc.pid, vmmap and env by name, as FreeBSD 11.4 does #23624
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23624"
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 brajankw on 2026-11-19T10:51:59Z.
What
sysctlanswers {1, 14, 1} (kern.proc.pid), {1, 14, 32} (kern.proc.vmmap) and {1, 14, 35} (kern.proc.env) with a pid as the fourth element, butsysctlnametomibandsysctlbynamereturned -1 withENOENTfor those names. So the usual FreeBSD way to reach these nodes, resolving the name and appending a pid to the MIB, failed. #14591 closed the same gap forkern.proc.proc.sysctlnametomibmaps the three names to three-element MIBs, as forkern.proc.pathnameandkern.proc.proc. The numbers are the ones FreeBSD 11.4'skern_proc.cregisterspidandenvunder, andvmmap(KERN_PROC_PID1,KERN_PROC_VMMAP32 andKERN_PROC_ENV35 insys/sysctl.h).On a PS5 (firmware 11.60, payload process), xXPBSXx's probes in #22788 got answers that are not
ENOENTfrom all three MIBs with the own pid: a 1,096-byte record from {1, 14, 1} (second probe, line 4; first probe, line 18 for the size query), 36 records of 144 bytes from {1, 14, 32} (fourth probe, line 8), and a size of 0 from {1, 14, 35} (third probe, line 9). So the nodes exist there under these numbers. The console's names for them were not measured.sysctlbynamegoes throughsysctlwith the three-element MIB, since FreeBSD 11.4'ssysctlbynameissysctlnametomibfollowed bysysctl. The MIB path is not changed, so through the name:EINVAL, assysctl_kern_procandsysctl_kern_proc_envdo when no pid follows the node;EPERM, whichsysctl_rootgives for these read-only nodes before their handler runs;EFAULT.kern.proc.pathnamealready answers this way by name. FreeBSD 11.4'ssysctl_kern_proc_vmmapdoes not check the length and reads a pid past the name. Herekern.proc.vmmapby name gets theEINVALits three-element MIB already gets.kern.proc.pid_tdis not mapped, although FreeBSD registers it at {1, 14, 17}: the same probes gotENOENTfor that MIB (third probe, lines 18 to 24), so the console likely has no such node. Its name keepsENOENTfrom both calls. The MIB {1, 14, 17} still answers here, as its debt entry says; this does not change it.Tests:
GuestSystemConfiguration.cpp.CheckNameToMiblists the three names with their MIBs.CheckProcessNodeNames, for each name:sysctlbynamefails withEINVALand leaves the buffer and the length alone, also for a size query and with both pointers null;EPERM, and an unreadable length withEFAULT.kern.proc.pid_tdstill getsENOENTfrom both calls.Debt: no fragment. No entry records the name gap, and the
kern.proc.pid,kern.proc.vmmapandkern.proc.enventries describe the MIBs, which this does not change.Tested
Linux (Debian 13, GCC 14.2.0, Release). Head
fb1fcf91ef, the single commit onmain3f4693be43.main74f685158e,guest_system_configurationaborts.ctestover the four tests whose sources callsysctl,sysctlbynameorsysctlnametomib, andguest_getrlimit: all pass onfb1fcf91ef. The four areguest_system_configuration,guest_kernel_sysctl_name_bounds,guest_kernel_sysctl_memory_nodesandguest_sce_net.ctest(6215 tests,-j 12) on2b0abd9797: 6200 passed. That is this change before review, which later only removed one block of the test, and before the rebase onto3f4693be43, which touched none of its files. Of the 15 failures:.gitdirectory, network access or a passwd entry for the user, and also fail onmainin this environment:conventions_git_errors,test_script_registration,web_library_assets,title_run,title_run_identity,guest_kernel_sys_login,guest_net_ctl,guest_getloginandguest_getlogin_no_session;agc_driverGPU cases fail the same way onmain3f4693be43:prepared_shaderswith itsindirect,uncachedanddebugforms, andstorage_file_write;agc_driver_image_table_packed_guardspassed 2 of 10 runs on its own both onfb1fcf91efand onmain3f4693be43, failing with "unrecoverable packed table format was not poisoned".python3 tools/check_conventions.py --base origin/main: passed.python3 tools/pr_overlap.py --branch fix/libkernel-sysctl-proc-pid-env-vmmap-names: no overlap with open pull requests. #22788 changes the same two files, in thekinfo_procrecord and its tests, and merges with this branch without overlap. The tool could not compare #18190, which conflicts withmain. That PR renamessysctl,sysctlbynameand the other exports of this file to_nid_no_patchforms and does not change the name handling.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-19T10:54:21Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
fb1fcf91ef: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-23T05:08:28Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed code and reported checks support merging.
What I ran
Reviewed head
fb1fcf91ef178257ab1519fbefc5f8629c74d6efusing the prepared diff andrepo_read.pysource reads. I did not run tests; the Linux test results in the PR description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run during this review. The description reports Linux checks and says Windows, macOS, and title execution were not tested. The change is limited to two files; both files listed as reviewed in the manifest were read.
files.jsonwas unavailable in the prepared bundle.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T12:52:12Z.
Review: COMMENTED
Built the branch’s changed sources and ran GuestSystemConfiguration on Linux against the existing runtime libraries. The test run passed and covered the kernel sysctl name lookup cases.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T14:08:43Z.
Review: APPROVED
I read the diff at
fb1fcf91ef. Windows 11 with GCC 15.2 and Linux (Ubuntu 24.04 in WSL2, GCC 13.3), merged intomainat6c6b29320fetogether with other open PRs (so not an isolated build).guest_system_configuration: pass on both.main's, the same test fails too.Not checked: a console.
AI-assisted: yes (Claude Code)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.