fix(libkernel): return EFAULT from module info and list queries for invalid memory pointers #13587
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13587"
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:52:06Z.
What
Fixes #13569.
FillModuleListandFillModuleInfo(underlyingsceKernelGetModuleList,sceKernelGetModuleList2,sceKernelGetModuleInfo, andsceKernelGetModuleInfo2), as well assceKernelGetModuleInfoFromAddr, directly dereferenced and wrote throughhandles,actual, andinfoguest pointers. If a non-null invalid or unwritable guest address was passed, the host crashed with a segmentation fault (SIGSEGV).This change:
GuestCopyIn_nid_no_patchto safely validatest_sizeinFillModuleInfo.GuestCopyOut_nid_no_patchto safely write tohandles,actual, andinfodestination buffers inFillModuleList,FillModuleInfo, andsceKernelGetModuleInfoFromAddr.SCE_KERNEL_ERROR_EFAULT(0x8002000e) if guest memory is unreadable or unwritable.core/libs/tests/GuestModuleInfo.cppcovering unwritablehandles,actual, andinfopointers.docs/dev/debt/libkernel.md.Tested
python tools/check_conventions.py --base origin/main.core/libs/tests/GuestModuleInfo.cppverifying that passing invalid memory pointers (0x10) returnsSCE_KERNEL_ERROR_EFAULT.Checklist
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-30T20:36:06Z.
Review: APPROVED
Verified a2ae599dd on Linux x86-64 (GCC 16.2.1, CachyOS kernel 6.2.10, Release, BUILD_TESTING=ON), isolated worktree at refs/pull/13587/head.
FillModuleInfovalidatesst_sizeviaGuestCopyIn_nid_no_patchand writes results viaGuestCopyOut_nid_no_patch;FillModuleListwriteshandlesandactualviaGuestCopyOut_nid_no_patch(staged through a local vector, so a badhandlesno longer partially writes before the ENOMEM path);sceKernelGetModuleInfoFromAddrzero-writes through the guarded copy. All returnSCE_KERNEL_ERROR_EFAULTon failure. No special-casing, no comments, matches the EFAULT-series pattern.handles,actual, andinfopointers (0x10) for GetModuleList, GetModuleList2, GetModuleInfo, and GetModuleInfo2. NotesceKernelGetModuleInfoFromAddrwith a badinfopointer is not directly tested (minor, its guards are the same helpers).guest_module_info: builds clean, passes 5/5 withctest --repeat until-fail:5.ModuleInfo.cpprestored tomain,guest_module_infoSEGFAULTs (reproduces issue #13569); rebuilt with the PR source it passes again.guest_sysmodule,guest_sysmodule_maps_scan,guest_unwind_module_info,guest_unwind_module_info_failureall pass. Other*module*ctest entries were Not Run/Failed because their executables were not built in the focused worktree — not related to this change.python tools/check_conventions.py --base origin/main: all checks passed.Not run: full ctest suite, title run, console measurement. Checklist is complete and truthful. Clean approve.