fix(libkernel): sceKernelSetVirtualRangeName rejects a 32 character name and accepts a length of 0 #16869

Merged
xXPBSXx merged 3 commits from upstream-pr/16869 into main 2026-11-12 01:54:44 +00:00
xXPBSXx commented 2026-11-07 19:27:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-11-07T19:27:22Z.


What

sceKernelSetVirtualRangeName cut a name of 32 or more characters to 31 and returned 0, and returned EINVAL for a length of 0. On a PS5 a name of 32 characters returns SCE_KERNEL_ERROR_ENAMETOOLONG (0x8002003f, errno 63) and the earlier name stays, a name of 31 characters is accepted, and a length of 0 returns 0. This does the same: a name of 32 or more bytes returns ENAMETOOLONG without changing the name, and a non-null address with a length of 0 returns 0. A null name (EFAULT) and a null address (EINVAL) are unchanged. The mapping calls that take a name (sceKernelMapNamedDirectMemory, sceKernelMapNamedFlexibleMemory, sceKernelMapNamedSystemFlexibleMemory) still cut a longer name to 31 characters through an internal helper, because what the console does there was not measured. A test pins the three results and the debt entry states the measurement. A title process was not measured.

Tested

Measured on a PS5 with firmware 11.60 (kernel_get_fw_version 0x11600005), from a homebrew payload process (ps5-payload-sdk v0.45, elfldr), on 2026-11-07 at 13:54 UTC. A title process may differ. The calls named a mapped 64 KiB range; the names were read back with sceKernelVirtualQuery.

Call PS5, payload process, firmware 11.60 AnyPS5 main before here
sceKernelSetVirtualRangeName(range, 0x10000, name of 31 characters) 0, the name is stored 0 0
sceKernelSetVirtualRangeName(range, 0x10000, name of 32 characters) 0x8002003f, the earlier name stays 0, the name is cut to 31 0x8002003f, the name stays
sceKernelSetVirtualRangeName(range, 0, name of 12 characters) 0 0x80020016 0

On this branch, Linux (WSL, Release) on main 571cab9f71db: with only the test commit guest_memory fails in 3 of 3 runs, and with the fix it passes in 3 of 3 runs. Nine other tests that name ranges indirectly pass with and without the fix. tools/check_conventions.py --base upstream/main passes. The probe source and its raw output are in the first comment. Not tested: Windows, macOS, the CI runner, a title process and any other firmware.

Overlap (P2, 2026-11-07, 17:20 UTC list of 1732 open pull requests, main 07c8408713, checked 18:46-18:52 UTC): of the 103 open pull requests that change core/libs/prx/libkernel/DirectMemory/Export.cpp, core/libs/tests/GuestMemory.cpp or docs/dev/debt/libkernel.md, each was merged with and without head ee24f1d956d0. None conflicts only with this branch (0 of 103); 42 conflict with main without it as well; the other 61 merge cleanly with and without it.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a (documentation and a host-independent memory check only)
  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5205102083 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16869). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-11-07T19:27:22Z. --- ### What `sceKernelSetVirtualRangeName` cut a name of 32 or more characters to 31 and returned 0, and returned `EINVAL` for a length of 0. On a PS5 a name of 32 characters returns `SCE_KERNEL_ERROR_ENAMETOOLONG` (0x8002003f, errno 63) and the earlier name stays, a name of 31 characters is accepted, and a length of 0 returns 0. This does the same: a name of 32 or more bytes returns `ENAMETOOLONG` without changing the name, and a non-null address with a length of 0 returns 0. A null name (`EFAULT`) and a null address (`EINVAL`) are unchanged. The mapping calls that take a name (`sceKernelMapNamedDirectMemory`, `sceKernelMapNamedFlexibleMemory`, `sceKernelMapNamedSystemFlexibleMemory`) still cut a longer name to 31 characters through an internal helper, because what the console does there was not measured. A test pins the three results and the debt entry states the measurement. A title process was not measured. ### Tested Measured on a PS5 with firmware 11.60 (`kernel_get_fw_version` 0x11600005), from a homebrew payload process (ps5-payload-sdk v0.45, elfldr), on 2026-11-07 at 13:54 UTC. A title process may differ. The calls named a mapped 64 KiB range; the names were read back with `sceKernelVirtualQuery`. | Call | PS5, payload process, firmware 11.60 | AnyPS5 `main` before | here | |---|---|---|---| | `sceKernelSetVirtualRangeName(range, 0x10000, name of 31 characters)` | 0, the name is stored | 0 | 0 | | `sceKernelSetVirtualRangeName(range, 0x10000, name of 32 characters)` | 0x8002003f, the earlier name stays | 0, the name is cut to 31 | 0x8002003f, the name stays | | `sceKernelSetVirtualRangeName(range, 0, name of 12 characters)` | 0 | 0x80020016 | 0 | On this branch, Linux (WSL, Release) on `main` `571cab9f71db`: with only the test commit `guest_memory` fails in 3 of 3 runs, and with the fix it passes in 3 of 3 runs. Nine other tests that name ranges indirectly pass with and without the fix. `tools/check_conventions.py --base upstream/main` passes. The probe source and its raw output are in the first comment. Not tested: Windows, macOS, the CI runner, a title process and any other firmware. Overlap (P2, 2026-11-07, 17:20 UTC list of 1732 open pull requests, `main` `07c8408713`, checked 18:46-18:52 UTC): of the 103 open pull requests that change `core/libs/prx/libkernel/DirectMemory/Export.cpp`, `core/libs/tests/GuestMemory.cpp` or `docs/dev/debt/libkernel.md`, each was merged with and without head `ee24f1d956d0`. None conflicts only with this branch (0 of 103); 42 conflict with `main` without it as well; the other 61 merge cleanly with and without it. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a (documentation and a host-independent memory check only) <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no --> AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
gabichuuuuu commented 2026-11-07 22:47:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-07T22:47:34Z.

Review: COMMENTED


The Windows cell you list as not tested. Head ee24f1d956 merged onto main 302864d48c (clean), Windows 11 x64, WinLibs GCC 15.2.0 r7, Release: guest_memory passes 3 of 3 runs, so the 31-character name, the 32-character ENAMETOOLONG with the earlier name kept, and the length-0 success hold on the MinGW build too. main's guest_memory passes as well on the same tree.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5815427632 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16869#pullrequestreview-5815427632). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-07T22:47:34Z. **Review:** COMMENTED --- The Windows cell you list as not tested. Head `ee24f1d956` merged onto `main` `302864d48c` (clean), Windows 11 x64, WinLibs GCC 15.2.0 r7, Release: `guest_memory` passes 3 of 3 runs, so the 31-character name, the 32-character `ENAMETOOLONG` with the earlier name kept, and the length-0 success hold on the MinGW build too. `main`'s `guest_memory` passes as well on the same tree. AI-assisted: yes.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!16869
No description provided.