Repository navigation
fix(libkernel): return EFAULT for a null virtual range name - #12986
Conversation
|
Windows run of this head (
AI-assisted: yes (Claude Code). |
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
rooklz
left a comment
There was a problem hiding this comment.
Reviewed at 968028c (base 5dc9aa3, which is in main fd9b3f6).
git merge-treeagainst main fd9b3f6 is clean,git diff --checkis clean, andtools/check_conventions.py --base upstream/mainpasses.tools/pr_overlap.py: 5 PRs sharecore/libs/tests/GuestMemory.cpp(#4449, #5021, #6321, #7105, #7631). All 5 already conflict with main, so this PR adds no new merge-order problem.clang++ -fsyntax-only(x86_64, macOS 15): the only error is the CMake-suppliedGUEST_MEMORY_MODULEdefine, which was already missing before this PR. The new code has no errors.- Harness: I copied main's
sceKernelSet/ClearVirtualRangeName,EraseRangeNamesandApplyRangeNameverbatim into a standalone file with the new check body, built with clang++ -std=c++20 and ASan+UBSan. Head passes, and all 12 mutants fail the check:- Set accepts a null address / zero length / null name: KILLED at the matching rows.
- Set without the overflow guard: KILLED.
- Set returns -1 instead of EINVAL: KILLED.
- Clear accepts a null address / zero length, or has no overflow guard: KILLED.
- Clear does nothing: KILLED at the final empty-name row.
- Set keeps the first name (no erase before insert): KILLED at the "second" row.
- A refused Set (overflow or zero length) still names the range: KILLED at the empty-name row before the first successful Set.
- Not blocking: the EINVAL contract (null address, zero length, null name, overflow) comes from the #50 model. No console measurement backs it, and #50's body doesn't cite one. If a measurement exists, citing it would help. Leaving the over-31-character name case out, as the PR does, is the right call.
adriadam10
left a comment
There was a problem hiding this comment.
Thanks for the test. The pass/fail mechanics look fine, but the expected values come from our own implementation rather than a reference, and one contradicts the references:
core/libs/tests/GuestMemory.cpp:204:sceKernelSetVirtualRangeName(mapping, length, nullptr) == einval. Both KytyPS5 (src/kernel/memory.cpp,KernelSetVirtualRangeName) and shadPS4 (src/core/libraries/kernel/memory.cpp,sceKernelSetVirtualRangeName) returnEFAULT(0x8002000e) for a null name. Either change the library and test toEFAULT, or show a measurement that the console returnsEINVAL.- Lines 202, 203, 205-208: null address, length 0 and
UINT64_MAXreturningEINVAL. Neither reference validates these (shadPS4'sCleardoesn't validate anything), so the test pins behaviour nothing here supports. Please cite where each comes from (console measurement, prospero-win, SDK header/doc), or drop the cases that have no source and note them as unknown indocs/dev/debt/libkernel.md.
The replace-then-clear checks (lines 210-214) are fine as they are.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KytyPS5 and shadPS4 return EFAULT for a null name. The test keeps that and the rename and clear checks, and drops the null address, zero length and past-the-end cases that no reference covers; the debt entry records them as unknown, with the 32-byte name limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
968028c to
287f43e
Compare
|
@adriadam10 thanks, agreed on both points. Updated in
AI-assisted: yes (Claude Code). |
|
Checked the null-name |
What
sceKernelSetVirtualRangeNamewith a null name returnedSCE_KERNEL_ERROR_EINVAL. KytyPS5 (src/kernel/memory.cpp,KernelSetVirtualRangeName) and shadPS4 (src/core/libraries/kernel/memory.cpp,sceKernelSetVirtualRangeName) both returnSCE_KERNEL_ERROR_EFAULT(0x8002000e) for it, so it now does too, checked before the other arguments as in both.CheckVirtualRangeNamesinguest_memory, on a 16 KiB flexible mapping: a null name returnsEFAULTand leaves the range unnamed; naming the range twice keeps the second name; clearing it empties the name.EINVAL. They are recorded as unknown indocs/dev/debt/libkernel.md, together with the 32-byte name limit, where shadPS4 returnsENAMETOOLONGand this library cuts the name to 31 characters.Tested
Windows 11 Home 26200, Ryzen 9 5900X, WinLibs GCC 15.2.0 r7, Release, on
main556547d.ctest --test-dir build -R '^guest_memory$' --repeat until-fail:3: passes 3 of 3 runs.EINVALagain,guest_memoryfails at the null-name check (GuestMemory.cpp:201). Restored, it passes again.python tools/check_conventions.py --base upstream/main: passed.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)🤖 Generated with Claude Code