fix(libSceNKWebKit): validate guest pointers in Region exports #27964
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27964"
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 JJenkx on 2026-11-27T22:42:14Z.
What
Complete guest-pointer validation across
core/libs/prx/libSceNKWebKit/src/Region.cpp:Region::Shape*, itsm_segmentsandm_spansvector headers/buffers, and activeGuestArena::HostWriteguards in_ZN7WebCore6Region5Shape9translateERKNS_7IntSizeE(with rollback on partial write failure) and inRegion::translate,rects,contains,intersects,unite,subtract,intersect,totalArea, copy construction, and copy assignment.GuestArenaPrepareHostRead_nid_no_patch+GuestReadable_nid_no_patch) beforeGuestCopyIn_nid_no_patchinLoadRegionand validate activeGuestArena::HostWriteguards acrossGuestCopyOut_nid_no_patchinStoreRegion, move construction, and move/copy assignment (eliminating remaining directselfdereferences flagged byguest_pointer_audit.py).WTF::TextStream&readability/writability andRegionreadability before mutating the stream in_ZN7WebCorelsERN3WTF10TextStreamERKNS_6RegionE, copyingindentviaGuestCopyIn_nid_no_patch/GuestCopyOut_nid_no_patchwith RAII restoration.core/libs/prx/libSceNKWebKit/tests/RegionGuestPointers.cppwith guarded/read-onlyShape, badm_shape, andTextStreamregression tests and adddocs/dev/debt/changes/fix-libSceNKWebKit-region-guest-pointers.md.Tested
/usr/local/bin/cmake --build /mnt/sas-ssd/AnyPS5-work/agy/build-spec --target nkwebkit_regionguestpointers_tests nkwebkit_regiongeometry_tests nkwebkit_roundedrectregion_tests nkwebkit_webcoredump_tests):Region.cpp):ctest -R '^nkwebkit_regionguestpointers$' --output-on-failurefailed (***Exception: SegFault, 0/1 passed).54fa3c4ba12):ctest -R '^nkwebkit_(regionguestpointers|regiongeometry|roundedrectregion|webcoredump)$' --output-on-failurepassed (4/4,0.01 seceach).python3 tools/guest_pointer_audit.py libSceNKWebKit: 0 hits inRegion.cpp.python3 tools/check_conventions.py --base origin/main: All conventions checks passed.python3 tools/pr_overlap.py --branch fix/libSceNKWebKit-region-guest-pointers: 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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-27T22:43:14Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
54fa3c4ba1:tools/check_conventions.pypassed.nkwebkit_regionguestpointers_testsbuilt cleanly.nkwebkit_regionguestpointers):core/libs/prx/libSceNKWebKit/src/Region.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T22:52:33Z.
Review: COMMENTED
Actionable comments posted: 6
c3a77db4-5116-4666-a756-77ba7769b2f7Reviewing files that changed from the base of the PR and between
073e0313f3and54fa3c4ba1.core/libs/prx/libSceNKWebKit/src/Region.cppcore/libs/prx/libSceNKWebKit/tests/RegionGuestPointers.cppdocs/dev/debt/changes/fix-libSceNKWebKit-region-guest-pointers.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-27T23:06:54Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
eabde85503:tools/check_conventions.pypassed.nkwebkit_regionguestpointers_testsbuilt cleanly.nkwebkit_regionguestpointers):core/libs/prx/libSceNKWebKit/src/Region.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T23:13:30Z.
Review: COMMENTED
Actionable comments posted: 2
f36b071f-a8c5-4ad2-a4f8-14741e1c183eReviewing files that changed from the base of the PR and between
54fa3c4ba1andeabde85503.core/libs/prx/libSceNKWebKit/src/Region.cppdocs/dev/debt/changes/fix-libSceNKWebKit-region-guest-pointers.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-11-28T05:39:22Z.
Review: APPROVED
Checked head
eabde85503. All on Windows 11 with WinLibs GCC 15.2 (Release), applied tomain4c7578e0a4together with #27997, #27996, #27978, #27975, #27973, #27971, #27969, #27967, #27958, #27950, #27949, #27946, #27945, #27943, #27938, #27936.tools/check_conventions.py --headandtools/debt_fold.py --checkpassed and the full build succeeded.nkwebkit_regionguestpointerspasses. In the full CPU suite (5,131 tests) the only failures are unrelated:windows_read_trap_unknownfails onmaintoo (fixed in #28028), andframe_capture_minimizeis a timeout under load that passes on its own.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T08:19:13Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Unchecked signed integer additions in shape translation can overflow for valid guest coordinates; checked build and test results were not run on this head.
What I ran
Reviewed head
eabde855031dab65aa6528de5527d98935016b86. Readdescription.md,commits.md,manifest.json, all ofdiff.patch, and the full text of each reviewed file:Region.cpp,RegionGuestPointers.cpp, and the technical debt change note. No commands or tests were run.Results
Findings
Blocking
core/libs/prx/libSceNKWebKit/src/Region.cpp:217andcore/libs/prx/libSceNKWebKit/src/Region.cpp:218:TranslateShapeGuestadds the supplied deltas directly to each segment coordinate and span y coordinate.Shape::translateis exported independently and accepts arbitraryIntSizedeltas; values nearINT_MAXorINT_MINcan overflow signedint, which is undefined behavior. Check each translated coordinate in a wider type before writing, and fail without modifying guest buffers if any result is out of range.Non-blocking
None.
Not verified
No tests or build checks were run. The author reports Linux tests and audit results in the PR description; these were not independently verified. No files were excluded from review.
To get this to a good state
Check shape coordinate additions for overflow before writing, then rerun the relevant Region tests and guest pointer audit on the new head.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T08:12:42Z.
Review: COMMENTED
The region fixture exercised invalid region and shape data, a read-only text stream, and unchanged text-stream fields when formatting fails.
I ran the exact fixture and changed translation unit in a focused Linux build linked against the project’s guest libraries.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T14:55:22Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes validate guest pointers before reading or writing Region data, and I found no defect that blocks merging.
What I ran
Reviewed head
bd228d1f5a395b22aac583240b2e0b4848f9babfagainst the prepared diff and manifest. I read all changed lines in the three files marked reviewed. Source-only inspection; no tests, build, or merged-preview check was run. The author reports tests on candidate54fa3c4ba12, not this head.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author-reported tests, guest pointer audit, conventions check, and overlap check were not run on the reviewed head. Console behavior was not verified. Files read:
core/libs/prx/libSceNKWebKit/src/Region.cpp,core/libs/prx/libSceNKWebKit/tests/RegionGuestPointers.cpp, anddocs/dev/debt/changes/fix-libSceNKWebKit-region-guest-pointers.md. The manifest lists no excluded files.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T15:00:22Z.
Review: COMMENTED
Actionable comments
58cac3ec-55b7-4213-9b30-869ee31376dbReviewing files that changed from the base of the PR and between
eabde85503andbd228d1f5a.core/libs/prx/libSceNKWebKit/src/Region.cppcore/libs/prx/libSceNKWebKit/tests/RegionGuestPointers.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T15:01:49Z.
Review: COMMENTED
Built the updated
Region.cppand ran the exactRegionGuestPointersfixture against the existing Linux runtime. It passed. The new overflow assertion checks that the failed translation leaves the original region geometry intact. The implementation uses widened deltas for the rollback as well.AI-assisted: yes.