Repository navigation
Conversation
…PthreadRwlockDestroy pthread_rwlock_destroy read *rwlock directly to return 0 for a statically initialized rwlock before calling scePthreadRwlockDestroy, so an unreadable rwlock pointer crashed the host. scePthreadRwlockDestroy already reads the slot with GuestCopyIn_nid_no_patch, returning EFAULT for an unreadable one and 0 for a null slot, so the direct read is dropped and the POSIX form now returns EFAULT (14) for an unreadable rwlock, as other pthread rwlock functions do. A null rwlock still throws.
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
What
pthread_rwlock_destroyread*rwlockdirectly to return 0 for a statically initialized (null) rwlock before callingscePthreadRwlockDestroy, so an unreadable rwlock pointer crashed the host (tools/guest_pointer_audit.py libkernellists it aspthread_rwlock_destroy_nid_postfix: parameter rwlock (dereference)).scePthreadRwlockDestroyalready reads the slot withGuestCopyIn_nid_no_patch: it returnsEFAULTfor an unreadable slot andSCE_OKfor a null one. The direct read is dropped, so the POSIX form now returnsEFAULT(14) for an unreadable rwlock, through the existingtoPosixmapping, and keeps returning 0 for a null slot without changing it. A null rwlock pointer still throws.Tests:
TestRwlockInitAndDestroyLifecycleincore/libs/tests/GuestKernelPthreadRwlockBounds.cppnow checks thatpthread_rwlock_destroyandscePthreadRwlockDestroyreturnEFAULTfor the unmapped pointer0x10, and thatpthread_rwlock_destroyof a null slot returns 0 and leaves it null.Overlap:
EINVALand keeps the*rwlock == nullptrread this PR removes (L43). Both changes can be kept; the second to merge needs a rebase of those two lines.mainand could not be compared by the tool. It renamespthread_rwlock_destroy_nid_postfixtopthread_rwlock_destroy_nid_no_patchand adds forwarders, keeping the body; the two touch neighbouring lines, so the second to merge needs a rebase there.Tested
Windows 11, WinLibs GCC 15.2.0 (
15.2.0posix-14.0.0-ucrt-r7), Ninja, Release,-DBUILD_TESTING=ON, base1f27e2abfa. No title or homebrew.ctest --test-dir build15 -R "guest_kernel_pthread_rwlock_bounds|guest_rwlock_retire|guest_kernel_rwlockattr_settype|guest_kernel_rwlockattr_bounds": 4/4 passed.Rwlock.cppchange stashed),guest_kernel_pthread_rwlock_boundsfails withSegFault.python tools/check_conventions.py: all checks passed.python tools/pr_overlap.py --branch fix/libkernel-pthread-rwlock-destroy-guest-slot: reports fix(libkernel): validate null pointers in pthread rwlock functions boykopovar/AnyPS5#14108 and could not compare feat(libs): mirror libkernel exports through libkernel_sys boykopovar/AnyPS5#18190; both compared by hand above.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