fix(libkernel): check getrusage output pointers #8988
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8988"
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 MarcZX10 on 2026-10-21T08:41:48Z.
What
Build
getrusageresults in local storage, then copy them to guest memory with the checked guest-write helper. Inaccessible non-null output pointers now return-1with guestEFAULTinstead of crashing while writing the structure. Invalidwhovalues are still rejected first withEINVAL; null pointers for supportedwhovalues still returnEFAULT.Regression coverage checks invalid
whoand invalid output pointers for self, thread, and children results.Tested
cmake --build build --target guest_getrusage_tests -j2passed.git diff --checkpassed.ctest --test-dir build --output-on-failure -R '^guest_getrusage$'could not reach assertions because the host CPU gate rejects this Xeon E5-1620 v2 (missing BMI1/BMI2, LZCNT, MOVBE, AVX2 and FMA).getrusageinvalid-pointer work.Checklist
main; no other open PR implements the same functionsImported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T09:45:54Z.
Windows data point for
0c4556156merged ontomainb5d763770(clean,git merge-treerc 0): Windows 10.0.19045, MinGW-w64 GCC 15.2.0, Release.ctest -N -R '^guest_getrusage$'lists exactly that one test;ctest --no-tests=error -R '^guest_getrusage$'was run three times per tree.core/libs/prx/libkernel/System/src/Process.cpprestored tomain(the new test cases kept): fails 3 of 3 with a segmentation fault (ctest reportsSEGFAULT).Not tested: other platforms, a title run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T13:24:48Z.
Review: APPROVED
Checked against main
6cd36e6517and FreeBSD 11.4 sys/kern/kern_resource.c (sys_getrusage / kern_getrusage):getrusagebody plus the 4 new test cases, and it merges cleanly.getrusage_nid_postfixstill writes throughusagedirectly (*usage = {},usage->ru_*), so this fix is still needed.kern_getrusagerejects an unknownwhowith EINVAL beforecopyoutcan fail with EFAULT, and children (who == -1) going throughWriteGuestand returning EFAULT on a bad pointer also matches copyout.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.