fix(libkernel): answer kern.proc.pid and pid_td for a live thread's id, as FreeBSD 11.4's pget does #21986
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21986"
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-17T00:45:25Z.
What
sysctl{CTL_KERN,KERN_PROC,KERN_PROC_PID, id} and itsKERN_PROC_INC_THREADform failed withESRCHfor anything but the calling process's pid. FreeBSD 11.4'ssysctl_kern_proclooks the id up withpget, which withoutPGET_NOTIDmaps an id abovePID_MAX(99999) to the process of that thread (thekern.proc.pid_tdentry indocs/dev/debt/libkernel.md).PID_MAXthat is the calling thread's or a live guest thread's id (pthread_getthreadid_npvalues start at 100000), and return the same records as for the pid. Other pids still fail withESRCH.GuestSystemConfiguration.cpp: the calling thread's id returns the process record; a worker thread's id returns every thread's record, the worker and the caller included; after the worker is joined its id fails withESRCH. The foreign-pid checks use pid 1 (or 2) instead ofpid + 1000, which could now be a thread id.kern.proc.pathname,kern.proc.envandkern.proc.vmmap, which still accept only the pid where FreeBSD 11.4 callspgetwithoutPGET_NOTIDtoo; that is a follow-up.Tested
Linux (Debian 13, GCC 14.2.0, Release), on
main258ab7b6bd.ctest -R '^guest_system_configuration$': passed.main'sSystemConfiguration.cppand this branch's test,guest_system_configurationaborts at the first thread-id check.ctest(5891 tests,-j 12) with this branch merged together with four unrelated fixes of mine: 5875 passed. The 16 failures are the set that fails onmainin the same environment: sixagc_drivercases (agc_driver_image_table_packed_guardspasses when run on its own) and ten that need a.gitdirectory, network or a passwd entry for the user.python3 tools/check_conventions.py --base origin/main: passed.python3 tools/pr_overlap.py --branch: no overlap with open pull requests.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-17T00:50:42Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
cf8666eb58: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