fix(libkernel): reject malformed ranges in sceKernelReleaseDirectMemory #2421
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2421"
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 Pouare514 on 2026-10-09T19:02:57Z.
What
sceKernelReleaseDirectMemory only rejected a negative start and a zero length, so malformed ranges reached the physical pool: a sub-page length silently freed a whole page while fragmenting the block map at byte granularity, and an out-of-range length walked the page table past the backing store. Validate page alignment of start and length plus the range bound up front and return EINVAL instead, mirroring DoMunmap.
Tested
Checklist
Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T19:41:49Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
aa77b2b8, merged ontomain8b393b6ein one build with 31 other PRs that had no Windows run.guest_memory.guest_offline_imports, broken by #2359 (reported there).No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T20:00:49Z.
Tested on Linux (CachyOS x86_64, Intel RPL-S iGPU / Mesa 26.3.0-devel / Vulkan 1.4.363, GCC 16.2.1) at
aa77b2b8:/tmp/anyps5_build) with zero warnings/errors.python3 tools/check_conventions.py --base origin/main --head HEAD-> PASS (0 errors).GuestMemory.cpp(CheckReleaseDirectMemoryRejectsInvalidRanges). Page-alignment checks and bounds validation againstDIRECT_MEMORY_SIZEcleanly reject unaligned and out-of-bounds ranges withSCE_KERNEL_ERROR_EINVAL.LGTM!
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T05:19:05Z.
Conflicts with main in
core/libs/prx/libkernel/DirectMemory/Export.cppafter #2236; please rebase.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:26:04Z.
Rebased onto current main (conflict with #2236 in
sceKernelReleaseDirectMemory: the range validation now runs beforeDirectMemoryViews). Build and ctest green on the rebase, includingguest_memory. Page alignment matches KytyPS5 and shadPS4 (EINVAL); merging.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T06:28:49Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/tests/GuestMemory.cppL7core/libs/tests/GuestMemory.cppL7-8Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:37:26Z.
The only red check was
write-watch (macos-15-intel):write_watch_threadstimed out at 30 s on a slow runner (the same job on macos-15 passes, and those tests don't touch libkernel). Re-running it; merging once green.