Repository navigation
fix(libkernel): drop undefined protection bits in sceKernelMemoryPoolBatch's protect operation, as sceKernelMprotect does - #22297
Merged
oneandonlydean merged 1 commit intoNov 17, 2026
Conversation
…Batch's protect operation, as sceKernelMprotect does Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ycbuzi
added a commit
to ycbuzi/AnyPS5
that referenced
this pull request
Nov 17, 2026
PrivacyOnion
approved these changes
Nov 17, 2026
PrivacyOnion
left a comment
Contributor
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 535808524b:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_kernel_batch_map_guest_pointersbuilt cleanly. - CTest (
guest_kernel_batch_map_guest_pointers):1/1 Test #5632: guest_kernel_batch_map_guest_pointers ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libkernel/DirectMemory/MemoryPoolExport.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/1 Test #5632: guest_kernel_batch_map_guest_pointers ...Subprocess aborted***Exception: 0.60 sec 0% tests passed, 1 tests failed out of 1 - Code reading:
- Verified sceKernelMemoryPoolBatch entry op=3 masking e.protect.prot & DefinedProtection (0x3F7) in MemoryPoolExport.cpp:92 matches DefinedProtection constant and FreeBSD 11.4 vm_mmap.c / sceKernelMprotect masking conventions
- Verified technical debt fragment format and file location at docs/dev/debt/changes/fix-libkernel-memory-pool-batch-protect-drops-undefined-bits.md matches repo guidelines
- Verified GuestKernelBatchMapGuestPointers.cpp test CheckPoolProtectDropsUndefinedBits allocates flexible memory, exercises batch protect op with undefined bits 0x09 and 0x0B, checks protection via sceKernelVirtualQuery, and cleans up via sceKernelMunmap
- Verified 64-bit/32-bit types, integer sign/masking behavior, concurrency, and lack of code comments in MemoryPoolExport.cpp
Looks Good To Me
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
sceKernelMemoryPoolBatchpassed a protect entry's protection toDoMprotectunmasked. A bit outside0x3F7, such as0x08, made the host protection conversion throw, and the batch's guard turned that intoSCE_KERNEL_ERROR_EINVAL.sceKernelMprotectdrops those bits, as a PS5 (firmware 13.60) does; see thesceKernelMprotect protection bitsentry indocs/dev/debt/libkernel.md, and FreeBSD 11.4 masks the argument insys/vm/vm_mmap.c. A pool batch protect is the same change of protection, so it now masks with the same0x3F7(DefinedProtection). The console was measured only throughsceKernelMprotect, so applying this to the pool batch is an inference. The commit and type-protect operations are unchanged, and unlikesceKernelMprotectthe batch still refuses a zero length and needs a mapped start.GuestKernelBatchMapGuestPointers.cpp: protecting a flexible page throughsceKernelMemoryPoolBatchwith0x09leaves protection 1, and then with0x0Bleaves 3.sceKernelMemoryPoolBatch protectentry. It says the masking was not measured on a console, and that the console's map calls andsceKernelMtypeprotectrefuse such bits instead. It is a separate entry so that it does not change thesceKernelMprotect protection bitsentry, which fix(libkernel): refuse undefined protection bits in sceKernelBatchMap's map operations, as a PS5 does #22040 and fix(libkernel): drop undefined protection bits in sceKernelBatchMap's protect operation, as sceKernelMprotect does #22051 already change.Tested
Linux (Debian 13, GCC 14.2.0, Release), on
main47b33132f9.ctest -R '^(guest_kernel_batch_map_guest_pointers|guest_memory.*)$': 5 passed.main, the new check aborts at thesceKernelMemoryPoolBatchcall, which does not return 0.ctest(6000 tests,-j 12) on this branch and my other five branches of this round, merged ontomain47b33132f9: 5985 passed. All 15 failures also fail onmainin the same environment:.gitdirectory, network access or a passwd entry for the user:conventions_git_errors,test_script_registration,web_library_assets,title_run,title_run_identity,guest_kernel_sys_login,guest_net_ctl,guest_getloginandguest_getlogin_no_session;agc_drivercases (agc_driver_image_table_packed_guardspasses when run on its own).python3 tools/check_conventions.py --base origin/main: passed.python3 tools/pr_overlap.py --branch: no overlap with open pull requests.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)