fix(libkernel_sys): read the kenv name within its 129-byte bound, as FreeBSD 11.4 does #21984
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21984"
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:16Z.
What
kenvcopied the name with the guest path copy, which reads up to 1024 bytes, and checked its length afterwards. An unterminated name of 129 readable bytes followed by an unreadable page therefore failed withEFAULT, where FreeBSD 11.4'ssys_kenvreads it withcopyinstr(name, KENV_MNAMELEN + 1), stops at 129 bytes and fails withENAMETOOLONG(the last sentence of thekenventry indocs/dev/debt/libkernel_sys.md).CopyGuestString_nid_no_patch(name, KenvNameLength + 1, ...), which returnsENAMETOOLONGwhen no NUL is found within the bound andEFAULTwhen it faults first. The helper that did the length check afterwards is gone.GuestKernelSys.cpp: 129nbytes ending at aPROT_NONEpage giveENAMETOOLONG; the last 128 of them giveEFAULT, ascopyinstrfaults on the 129th byte.KENV_DUMPsize the console reports stays open.Tested
Linux (Debian 13, GCC 14.2.0, Release), on
main258ab7b6bd.ctest -R '^guest_kernel_sys$': passed.main'sExport.cppand this branch's test,guest_kernel_sysfails withKernel sys check failed at line 1244 (guest errno 14), the 129-byte case.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: failed closed on #9389 and #17936, which conflict withmain; neither diff toucheskenvor its test.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:48:49Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
98d7559fe5:tools/check_conventions.pypassed.guest_kernel_sys_testsbuilt cleanly.guest_kernel_sys):core/libs/prx/libkernel_sys/Export.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me