libkernel: ksem_getvalue faults on invalid memory pointers instead of returning EFAULT #13951
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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-31T13:45:34Z.
What happens
ksem_getvalue(core/libs/prx/libkernel/Semaphore/src/Ksem.cpp:150) crashes the host process withSIGSEGVwhen passed an invalid or unwritable guest memory pointer (such asreinterpret_cast<int*>(0x10)).In FreeBSD,
ksem_getvalueis backed bysys_ksem_getvalue(sys/kern/uipc_sem.c), which safely writes to user-space memory viacopyout, returningEFAULT(errno 14) when the memory is unmapped or unwritable. In AnyPS5,ksem_getvalue_nid_postfixdirectly assigned to*valuewithout checking destination writability viaGuestCopyOut_nid_no_patch.Title, test or build step
core/libs/tests/GuestKernelSysKsem.cppAnyPS5 commit
origin/mainat828ac0b2aeSystem
Windows 11 / Linux x86_64, GCC 15.2.0, Release
Steps to reproduce
Call
ksem_getvalue_nid_postfix(id, reinterpret_cast<int*>(0x10)).Log
What was checked
Verified on unmodified
origin/mainthat passing0x10crashes withSIGSEGV. WithGuestCopyOut_nid_no_patch, the call safely returns-1witherrno == GuestEfault(14).