fix(libkernel): return EFAULT from direct memory queries for invalid memory pointers #13576
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13576"
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:36:35Z.
What
Fixes #13566.
sceKernelAvailableDirectMemorySize,sceKernelGetDirectMemoryType, andsceKernelDirectMemoryQuerydirectly dereferenced guest output pointers (phys_addr_out,size_out,memory_type,start,end, andinfo). When a guest passed a non-null pointer into unmapped or read-only memory, the host process crashed withSIGSEGV.This change:
GuestCopyOut_nid_no_patchto safely write output values to guest destination buffers insceKernelAvailableDirectMemorySize,sceKernelGetDirectMemoryType, andsceKernelDirectMemoryQuery.SCE_KERNEL_ERROR_EFAULT(0x8002000e) when destination memory is inaccessible.core/libs/tests/GuestMemory.cpp.docs/dev/debt/libkernel.md.Tested
python tools/check_conventions.py --base origin/main.core/libs/tests/GuestMemory.cppverifying that passing invalid memory pointers (0x10) returnsSCE_KERNEL_ERROR_EFAULT.Checklist
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-30T21:31:45Z.
Review: COMMENTED
First Linux run of head
a347c4ef7e, merged ontomain6472c708ae(clean merge). Ubuntu 26.04, i7-8700, GCC 15.2, Release,BUILD_TESTING=ON, Ninja.guest_memory: passes 3/3.public_headers: passes.core/libs/prx/libkernel/DirectMemory/Export.cppreverted tomain(new test kept),guest_memorysegfaults 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.