Repository navigation
fix(npcommon): validate guest address pointer in sceNpAllocateKernelMemoryNoAlignment - #22107
Conversation
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 10aa6c6c19:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_np_common_runtime_testsbuilt cleanly. - CTest (
guest_np_common_runtime):1/1 Test #900: guest_np_common_runtime .......... Passed 0.36 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libSceNpCommon/Runtime.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/1 Test #900: guest_np_common_runtime ..........***Exception: SegFault 0.23 sec 0% tests passed, 1 tests failed out of 1 - Code reading:
- Verified GuestCopyOut_nid_no_patch safely handles unwritable guest destination pointers and prevents host segfaults
- Verified sceNpFreeKernelMemory cleanup on GuestCopyOut_nid_no_patch failure to prevent memory leaks
- Verified errno preservation across GuestCopyOut_nid_no_patch call
- Verified documentation fragment docs/dev/debt/changes/fix-libSceNpCommon-allocateKernelMemory-copyout.md follows repo conventions and records console behavior status
- Verified test coverage in core/libs/tests/GuestNpCommonRuntime.cpp correctly validates failure path with invalid address 0x10 and errno preservation
Looks Good To Me
|
Windows result for head Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release,
AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine. |
|
Built and ran it on Windows (11, MSYS2 UCRT64, GCC 16.2) at No defects, and the failure handling is the part worth calling out: if (!copied) {
sceNpFreeKernelMemory(memory);
return NP_ERROR_INVALID_ARGUMENT;
}Freeing on an unpublishable address is right, and it is safe from a double free for a specific reason — the caller never receives the address, so it has nothing to free later. Returning The added test line and the debt fragment both match the change. Nothing else to flag on an 18-line diff. Run in a local Windows environment; no changes pushed. AI-assisted: yes |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The change at head 10aa6c6c197844315706f2490e1cb51524985439 checks the guest output pointer, releases the mapped memory on copy failure, and preserves errno; the changed implementation and test support merging.
What I ran
- Inspected the prepared diff and targeted source and test ranges using
repo_read.pytools. No build or tests were run; the commands in the PR description are author-reported.
Results
| Check | Result | Note |
|---|---|---|
| Changed implementation and adjacent helpers | passed | Allocation cleanup path inspected |
| Changed runtime test | passed | Invalid output pointer and errno assertion inspected |
| Build and tests | not run | Reported by author only |
Findings
Blocking
None.
Non-blocking
None.
Not verified
The complete changed-file texts under review/files/ and files.json were not accessible via the available reader tools. The implementation and test hunks were read from the pinned repository head. The documentation change was only inspected in the diff. Build, unit tests, conventions check, and console behavior were not independently verified. The PR description reports successful build, unit test, and conventions check; those results were not run by this review.
To get this to a good state
Nothing is required.
|
Tested head Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release,
Whole batch: the full This is one combined tree, not a run of this PR alone. AI-assisted: yes (Claude Code) |
|
Tested
AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports. |
What
Validate guest destination pointer via
GuestCopyOut_nid_no_patchinsceNpAllocateKernelMemoryNoAlignment, unmapping memory on failure and preserving caller errno.Tested
/tmp/anyps5_build)guest_np_common_runtime_tests)python3 tools/check_conventions.py --base origin/mainpasses cleanlyChecklist