Repository navigation
Conversation
… guest copy scePthreadAttrSetstackaddr read the attribute handle straight from the guest slot, so an unmapped slot crashed the host. It now loads the handle with LoadAttribute, as scePthreadAttrSetstack and the other attribute exports do: an unreadable slot returns SCE_KERNEL_ERROR_EFAULT, and a null slot, a null handle or a null address still return SCE_KERNEL_ERROR_EINVAL.
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
What
scePthreadAttrSetstackaddrread the attribute handle with*attrstraight from the guest slot, so an unmapped slot crashed the host. Every otherscePthreadAttr*setter and getter already loads the handle throughLoadAttribute, which copies it in withGuestCopyIn_nid_no_patchand returnsSCE_KERNEL_ERROR_EFAULTfor an unreadable slot.scePthreadAttrSetstackaddrnow usesLoadAttributetoo, asscePthreadAttrSetstackbeside it does.A null
attr, a slot holding a null handle and a nulladdrstill returnSCE_KERNEL_ERROR_EINVAL. With a usable slot the result is the same as on main. The only change is for an unreadable slot: it now returnsEFAULTinstead of crashing, even whenaddris null, because the slot is read first. The attribute object itself is a host allocation made byscePthreadAttrInit, so writingstackAddressthrough the loaded handle is not a guest access.scePthreadAttrGetin the same file also reads*attrdirectly. It is left alone because open PRs boykopovar#8041 and boykopovar#9938 change its body.Not changed (false positives or covered elsewhere): the rest of the libkernel
tools/guest_pointer_audit.pylist.sysctl,sysctlbyname,sysctlnametomib,sigaction,sigaltstack,sceKernelFutimes,sceKernelCheckReachability,pthread_attr_getschedparamandscePthreadAttrGetschedparamalready copy their arguments in or out and then rebind the parameter to the host copy, or only take a member's address forStoreOutput. The audit does not follow that rebinding.JoinThread_nid_no_patchonly gets host copies from its callers (pthread_timedjoin_npcopies the deadline in,scePthreadJoinpasses null).scePthreadOnce,scePthreadMutexUnlockand_umtx_opdeliberately work on the guest word withstd::atomic_ref.scePthreadMutexDestroyalready checks the slot with a guest copy first.__tls_get_addr,ktimer_create, sockets,dlsym, unwind info, event flag and semaphore waits).Overlap
python3 tools/pr_overlap.py --names scePthreadAttrSetstackaddr→ main implemented. The only open PRs listed are the libkernel_web/libkernel_sys mirror PRs feat(libs): mirror libkernel exports through libkernel_web boykopovar/AnyPS5#18112 and feat(libs): mirror libkernel exports through libkernel_sys boykopovar/AnyPS5#18190, which list every libkernel export.python3 tools/pr_overlap.py --branch fix/libkernel-pthread-attr-stackaddr-guest-pointers→ no overlapping function. The tool could not comparePthread/src/Attr.cppwith fix(libkernel): honor caller-provided pthread stacks boykopovar/AnyPS5#9938 because that PR conflicts with main. Checked by hand again after the rebase: inPthread/src/Attr.cppfix(libkernel): honor caller-provided pthread stacks boykopovar/AnyPS5#9938 changes onlyscePthreadAttrGet.Tested
Arch Linux, GCC, Release.
guest_pthread_attr(core/libs/tests/GuestPthreadAttr.cpp) has new checks:CheckBadPointers: an unmapped (0x10) slot and an unreadable guard page returnSCE_KERNEL_ERROR_EFAULT, with a validaddrand with a null one.EINVAL. On a live attribute, a nulladdrreturnsEINVAL, and a set address reads back throughpthread_attr_getstackaddr.Mutation check (repeated after the rebase): with
Pthread/src/Attr.cppreset toorigin/mainand the new checks kept,guest_pthread_attrsegfaults.Re-run after rebasing onto
origin/main0a025bd:ctestpassed all 421 tests registered bycore/libs/prx/libkernelpluspublic_headers(422/422).tools/check_conventions.py --base origin/mainpasses.tools/guest_pointer_audit.py libkernelno longer listsscePthreadAttrSetstackaddr.tools/progress.py --module libkernelgives 719 done / 39 todo, the same asorigin/main.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)Summary by CodeRabbit