fix(libkernel): sceKernelMapNamedSystemFlexibleMemory maps and then rejects a name of 32 characters or a null name #17718
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17718"
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 xXPBSXx on 2026-11-09T12:25:26Z.
What
sceKernelMapNamedSystemFlexibleMemorythrew for a name of 32 or more characters and for a null name. On a PS5 the call maps the memory first and then refuses the name: a name of 32 characters returnsSCE_KERNEL_ERROR_ENAMETOOLONG(0x8002003f, errno 63) and a null name returnsSCE_KERNEL_ERROR_EFAULT(0x8002000e, errno 14), and in both cases the mapping exists without a name of its own; names of 8 and 31 characters are stored (cases 4.1 to 4.4, lines 36 to 39 of the raw output in the first comment). This does the same: the name is read before the mapping as before, a null name returnsEFAULTafter the mapping and a name of 32 or more bytes returnsENAMETOOLONGafter it, and the range is left mapped and not named. A test pins the two errors and a non-null mapping, and for the 32-character name that the range is not named with the name cut to 31. The debt entry of the function states the measurement through the existing debt fragment of this function (the one entry, not a second fragment). The same run showed that the flags 0x8000 are accepted (0, the name is set) and the protection 0x800 is refused withEINVALand no mapping (cases 4.5 and 4.6, lines 40 and 41); the entry records both and neither is changed here. A name that cannot be read still throws, which was not measured. A title process was not measured, and a name of 33 or more characters follows from the 32-character case.sceKernelMapNamedDirectMemoryhas the same name checks in #16945; this change does not depend on it (different function and test file, and each pull request changes the debt in its own fragment).Tested
Measured on a PS5 with firmware 11.60 (
kernel_get_fw_version0x11600005), from a homebrew payload process (ps5-payload-sdk v0.45, elfldr), on 2026-11-08 at 04:33 UTC (theutcin thePROBEline is the console's own clock, about 1 h 42 min ahead). A title process may differ. The calls mapped 64 KiB; the mapping was read back withsceKernelVirtualQuery. The cases are 4.1 to 4.6, lines 36 to 41 of the raw output in the first comment.mainbeforesceKernelMapNamedSystemFlexibleMemory(64 KiB, name of 31 characters)sceKernelMapNamedSystemFlexibleMemory(64 KiB, name of 32 characters)anon:..., line 38)sceKernelMapNamedSystemFlexibleMemory(64 KiB, NULL name)anon:..., line 39)Red and green on one base: Windows 10 Pro (MinGW GCC, Release,
cmake -DBUILD_TESTING=ON,ninja -j4 guest_system_flexible_memory_tests,ctest -R ^guest_system_flexible_memory$, one worktree, a checkout, cmake, ninja and ctest per phase), baseupstream/maindd9b766645bb: on the baseguest_system_flexible_memorypasses (23:41 UTC on 2026-11-19); with the test commitcf471c208974it fails (23:43 UTC; exit code 0xc0000409, and the output shows an unhandledstd::runtime_errorand an abort, which is the throw of the old code; the message of the exception readsname of 32 bytes or more, which is the first new call, the 32-character name); with the fix commit16cae035c8a9it passes (23:44 UTC); with the documentation commit3583d06ce82dit passes (23:46 UTC).tools/check_conventions.py --base dd9b766645bbandtools/debt_fold.py --checkpass on the head, the entry is 957 characters without the list marker, and a merge intoupstream/mainc8eb2aac700was checked withgit merge-treeand is clean. The change is 3 files, +13/-5, with no new comments in code. Linux and macOS were not run here; CI will. Not tested: a title process and any other firmware.Overlap: the other open pull requests that change the files of this branch (
core/libs/prx/libkernel/DirectMemory/Export.cpp,core/libs/tests/GuestSystemFlexibleMemory.cppand the existing fragmentdocs/dev/debt/changes/fix-libkernel-range-name-guest-copy.md, which is onmainunfolded, for the entry ofsceKernelMapNamedSystemFlexibleMemoryindocs/dev/debt/libkernel.md), found by reading the changed files of all 2028 open pull requests at about 09:03 to 09:23 UTC on 2026-11-20, by reading what they change in every file whose path containsDirectMemory,SystemFlexible,GuestMemoryorVirtualRangeand in all debt files forsceKernelMapNamedSystemFlexibleMemory,NameVirtualRange,CopyRangeNameand the fragment name, and by searching their titles and branch names forSystemFlexible,MapNamedSystemandrange name, were checked on 2026-11-20 at about 09:32 UTC againstmainc8eb2aac700together with this head: the branch is based ondd9b766645b, an ancestor of it, merges intomainwithout a conflict, andtools/debt_fold.py --checkapplies the fragment together with every other fragment onmainwithout an error. This branch replaces the earlier headf65c9ef5cacof this pull request, which is not an ancestor of the new head; the earlier head carried the three commits of the first version of #16945 in front of its own. #16945 (fix(libkernel): sceKernelMapNamedDirectMemory returns ENAMETOOLONG for a 32 character name and EFAULT for a NULL name) changes the neighbouring function in the sameExport.cppand a different test file, and merges with this head without a conflict. #21569 (fix(libkernel): bound virtual range names as the console does) and #19486 (feat(libSceNKWebKit): implement WKContextGetGeolocationManager and WKGeolocationManager functions) showNameVirtualRangeor the fragment in their patches, #21569 as unchanged context of a call and #19486 as lines of an older state ofmain, whose head is identical tomaininExport.cpp, the test and the fragment; neither changes a line ofsceKernelMapNamedSystemFlexibleMemory. The other pull requests that listDirectMemory/Export.cpp(#24073, #24063, #23613, #22051, #22040, #22013, #19183, #18190, #17936 and #17553) change other functions of the file. With this branch applied tomain, all 68 pull requests that list one of these files or matched a name were merged on top of it: 31 of them already conflict withmainalone, and none has more conflicting files with this branch than without it. Unpublished local branches that touch these files were compared as well (150 branches); the only one that names the function orNameVirtualRangein a changed line is an earlier local copy of the first version of #16945, which this branch no longer carries. The merged result was not built or run beyond the red and green runs above.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T09:58:56Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed implementation and regression coverage support merging.
What I ran
Reviewed head
3583d06ce82d1002daa13e98a65244fd561cacdd. No commands or tests were run in this review; the PR description reports Windows test runs, convention and debt checks, and a clean merge check, which I did not independently run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I read
core/libs/prx/libkernel/DirectMemory/Export.cpp,core/libs/tests/GuestSystemFlexibleMemory.cpp, anddocs/dev/debt/changes/fix-libkernel-range-name-guest-copy.md; all three files listed as reviewed were read. No changed files were excluded. I did not independently run tests, check CI, verify the PS5 behavior, or build and run the merged result. The test verifies the too-long name is not retained, but does not assert the precise anonymous range name described in the PR.To get this to a good state
Nothing is required.