fix(libkernel): return EFAULT from cancellation state and type setters for unwritable pointers #13582
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13582"
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 pushkarreddyy on 2026-10-30T18:47:48Z.
What
Fixes #13568.
scePthreadSetcancelstate,scePthreadSetcanceltype,pthread_setcancelstate_nid_postfix, andpthread_setcanceltype_nid_postfixwroteold_stateandold_typedirectly to guest pointers without copy safety verification. When called with an unwritable non-null pointer (e.g. into read-only memory or unmapped space), the host crashed withSIGSEGV.This change:
GuestCopyOut_nid_no_patchinscePthreadSetcancelstateandscePthreadSetcanceltypeto safely copy the previous cancellation state/type to guest memory.SCE_KERNEL_ERROR_EFAULT(0x8002000e) and14(EFAULT) without mutating the thread's cancellation state or type on copy-out failure.core/libs/tests/GuestPthreadCancel.cpptesting unwritable pointers and ensuring state remains unaltered on failure.docs/dev/debt/libkernel.md.Tested
guest_pthread_cancelpasses 3 of 3 runs (verified by @maskym, @JJenkx, @gabichuuuuu); negative control with unmodifiedThread.cppreproduces access violation0xc00000055 of 5 runs (verified by @bunbeans2-arch).guest_pthread_cancelpasses 3 of 3 runs (verified by @jotitadev).python tools/check_conventions.py --base origin/main(passed: 0 findings).Checklist
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-30T21:31:47Z.
Review: COMMENTED
First Linux run of head
7b18b9ff4a, merged ontomain6472c708ae(clean merge). Ubuntu 26.04, i7-8700, GCC 15.2, Release,BUILD_TESTING=ON, Ninja.guest_pthread_cancel: passes 3/3.ctest -R ^guest_pthread_cancel: 27/27.public_headers: passes.core/libs/prx/libkernel/Pthread/src/Thread.cppreverted tomain(new test kept),guest_pthread_cancelsegfaults 3/3. So on Linux the new checks fail without the fix.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.