feat(libkernel): answer kern.proc.env for the calling process #9736
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9736"
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 LeandroLP23 on 2026-10-22T10:58:44Z.
What
PS5VR (PPSA99177) stops at start-up, right after it loads
libSceVrTracker2:That MIB is {
CTL_KERN,KERN_PROC,KERN_PROC_ENV, pid}, and the title asks for its own pid.sysctlnow answers it as FreeBSD 11'ssysctl_kern_proc_envdoes for the calling process:environlibkernel exports and libc'sgetenvboth begin empty. So the call returns 0 bytes. FreeBSD reads the start-up strings, not latersetenvchanges, so those changes don't show up there either.EINVALfor a MIB without exactly one pid.ESRCHfor any other pid, -1 included, aspgetgives.EPERMfor a write. These are the same rules as thekern.proc.vmmaphandler next to it.Which variables, if any, the console starts an application with is unverified. That is recorded in
docs/dev/debt/libkernel.md.Tested
Windows 11, Ryzen AI 7 350 / Radeon 860M, WinLibs GCC 15.2, Release.
maincc0078595d: the title ends with theunsupported MIB 1.14.35.<pid>exception above.main8b3a6ba88d(run again after the rebase): it gets past the call and lists its library (library: list Library -> ok, 7 items). It then shows its TV screen: the PS5VR logo, "Put on your PlayStation VR2" and the phone-link QR code. It also logsvr: headset setup failed, as expected with no PlayStation VR2 attached (sceHmd2Initialize->0x81110016).guest_system_configurationhas a newCheckEnvSysctl, which covers:errnounchanged;It fails on
main'sSystemConfiguration.cppand passes with this change.ctest -R "sysctl|system_config|guest_process": 6 of 6 pass.python tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.pyon the rebased branch:docs/dev/debt/libkernel.mdline afterkern.proc.vmmap, so the new entry sits beforekern.proc.vmmapinstead. A local merge of #8910 into this branch is clean.kern.smp.maxcpus,kern.stackprot,kern.sched.name,kern.timecounter.hardware). It already conflicts withmainindocs/dev/debt/libSceIme.md, a file this PR doesn't touch.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 MarcZX10 on 2026-10-22T11:54:45Z.
I checked this against current
main: the PR is 11 commits behind, although it still merges cleanly. Please refresh the branch and rerun the focusedsysctl/system-configuration tests and overlap check against the current tree before merge. The title-specificUnblocks: PPSA99177 #5745entry is present; the hosted full Linux/Windows jobs are skipped on PRs by repository policy.Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-22T12:57:42Z.
Rebased on current
main8b3a6ba88d(0 behind), head6e1df42286. Full build on Windows (WinLibs GCC 15.2, Release), then:ctest -R "sysctl|system_config|guest_process": 6 of 6 pass,guest_system_configurationincluded.sysctlcall and reacheslibrary: list Library -> ok, 7 items, as before the rebase.check_conventions.py --base origin/mainpasses.pr_overlap.py: #8910 changed the debt line right afterkern.proc.vmmap, where the new entry was, so I moved the entry one line up, beforekern.proc.vmmap. A local merge of #8910 into this branch is now clean. #8553 already conflicts withmainindocs/dev/debt/libSceIme.md, which this PR doesn't touch.The PR description is updated to match.
Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-22T13:08:06Z.
Review: APPROVED
Checked against main
3ca07d086dand FreeBSD releng/11.4sys/kern/kern_proc.c(sysctl_kern_proc_env, lines 1975-2001, node flags at 2956):namelen != 1, ESRCH frompgetfor a foreign pid and for -1, and EPERM for a write from theCTLFLAG_RDnode before the handler runs. The EPERM-before-EINVAL order in the new branch matches too.environ_nid_postfixstarts asemptyEnvironment(libkernel/System/src/Process.cpp:224) and libc's table starts empty (libc/src/Environment.cpp:26). The console's real start-up environment is recorded in the debt entry.cc0078595dtouches the three files, so the refresh MarcZX10 asked for should be conflict-free.CopyOut(nullptr, 0, ...)ends instd::memcpy(oldValue, nullptr, 0), which is formally UB even with a zero length. A one-byte static empty buffer as the source would sidestep it. Not blocking.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.