feat(libkernel): implement getresuid and getresgid #8894
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8894"
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 slopgobblercobbler on 2026-10-21T04:58:04Z.
What
Implement
getresuid_nid_postfixandgetresgid_nid_postfix(FreeBSD syscalls 360 and 361) incore/libs/prx/libkernel/System/src/Process.cpp, test them inGuestCredentials.cpp, and updatedocs/dev/debt/libkernel.md.Why
FreeBSD 11.4 provides
getresuidandgetresgid(sys/kern/kern_prot.c) to retrieve the real, effective, and saved user and group IDs of the process.AnyPS5 models a guest environment running as root with real, effective, and saved IDs set to 0.
getresuidandgetresgidaccept nullable output pointers for real, effective, and saved IDs.sys_getresuidandsys_getresgid.errnoleft untouched on success.Tested
Windows 11 x64:
core/libs/tests/GuestCredentials.cppwith unit test coverage:errnois untouched on success.python tools/check_conventions.py --base upstream/main --head HEAD.python tools/check_main_sync.py: HEAD is 1 ahead and 0 behind upstream/main, clean merge.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 github-actions[bot] on 2026-10-21T04:58:46Z.
Progress report (
e072e88→ 21154fc)📈 System libraries: 42.11% (+0.01%, +2 implemented functions)
✅ 2 implemented
getresgid_nid_postfixgetresuid_nid_postfixImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T05:02:18Z.
Review: APPROVED
Reviewed the implementations and focused tests. They match the documented guest-root model: independently write zero to each non-null output, accept null outputs, return success, and leave errno untouched. The tests cover those cases.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T05:36:36Z.
One additional edge case may be missing: invalid non-null output pointers. FreeBSD 11.4 documents EFAULT for an invalid address passed to getresuid/getresgid (https://man.freebsd.org/cgi/man.cgi?query=getresgid&sektion=2&manpath=FreeBSD+11.4-RELEASE+and+Ports), and sys_getresuid/sys_getresgid use copyout for each non-null pointer. These direct stores would fault the host on an unmapped pointer instead of returning -1 with errno 14. I confirmed the analogous native Linux syscall behavior with getresuid((uid_t*)1, NULL, NULL): -1/EFAULT. The null-output cases in the new tests are useful and should remain; could you add a guarded/inaccessible non-null output case and map the failure to guest EFAULT?
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T06:33:05Z.
I prepared a two-commit follow-up on my fork: 85f030a59f validates each non-null output range and uses safe OS copyout to return guest
EFAULTinstead of faulting the host; 21154fc9ab adds invalid-pointer regression cases for both functions. Branch:codex/8894-getresuid-efault.Checks on the branch: conventions pass,
git diff --checkpasses, andProcess.cpppasses Linuxc++ -std=c++20 -fsyntax-only. I could not runguest_credentials: CMake configuration stops because this workspace has an empty SDL2 submodule and lacks XRandR development support. The commits are available if you want to cherry-pick them.Imported from boykopovar/AnyPS5. Originally posted by slopgobblercobbler on 2026-10-21T14:10:58Z.
Thank you @MarcZX10 for the thorough review, approval, and for providing the guest pointer validation helper commits! We have integrated commits 85f030a59 and 21154fc9a covering guest \EFAULT\ handling and test verification into the branch and confirmed all local unit tests and repository conventions pass cleanly.
Pull request closed