fix(libSceNKWebKit): validate guest pointers in HistoryItem exports #27950
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27950"
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:20:41Z.
What
Validate guest pointers across all 36 existing
WebCore::HistoryItemexports incore/libs/prx/libSceNKWebKit/src/HistoryItem.cpp:std::invalid_argumentbehavior for null object/argument pointers and existingNotImplemented_nid_no_patchbehavior when replacing non-nullstateObject/formData.GuestArenaPrepareHostRead_nid_no_patch+GuestReadable_nid_no_patch) and copy nested fields (CachedPage,IntPoint,HistoryItemVectorStorage,StringImpl*, child pointers, and string character ranges) viaGuestCopyIn_nid_no_patchin getters andchildItemWithTarget.GuestArena::HostWriteguards in constructors (C1/C2) and setters (set*,setDocumentState,addChildItem,setStateObject,setFormData), plan alias-awareWTF::StringImplretains and releases (checking overflow, terminating flags, and cycle/truncatedSharedSubstringchains) before publishing viaGuestCopyOut_nid_no_patchwith rollback on publication failure, and callNotImplementedAt_nid_no_patchon invalid guest memory.core/libs/prx/libSceNKWebKit/tests/HistoryItem.cppand record the technical debt fragment indocs/dev/debt/changes/fix-libSceNKWebKit-history-item-guest-pointers.md.Tested
/usr/local/bin/cmake --build /mnt/sas-ssd/AnyPS5-work/agy/build-spec --target nkwebkit_historyitem_tests nkwebkit_historyitemurl_tests):HistoryItem.cpp):ctest -R '^nkwebkit_historyitem$' --output-on-failurefailed (Subprocess aborted, 0/1 passed).2621a4ad6d9):ctest -R '^nkwebkit_historyitem(url)?$' --output-on-failurepassed (2/2,nkwebkit_historyitem0.02 sec,nkwebkit_historyitemurl0.01 sec).python3 tools/guest_pointer_audit.py libSceNKWebKit: 0 hits inHistoryItem.cpp.python3 tools/check_conventions.py --base origin/main: All conventions checks passed.python3 tools/pr_overlap.py --branch fix/libSceNKWebKit-history-item-guest-pointers: 0 overlaps across 2090 open PRs;#20938conflicted with base and was manually inspected —#20938only adds 9 distinct new exports (C1Ev/C2Ev, 2-arg/3-arg constructors,D1Ev/D2Ev,copyEv) and does not touch any of the 36 exports modified here.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:23:16Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
2621a4ad6d:tools/check_conventions.pypassed.nkwebkit_historyitem_testsbuilt cleanly.nkwebkit_historyitem):core/libs/prx/libSceNKWebKit/src/HistoryItem.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:30:16Z.
Review: COMMENTED
Actionable comments posted: 7
f692f135-e952-4358-a8df-1597a32bc8dbReviewing files that changed from the base of the PR and between
073e0313f3and2621a4ad6d.core/libs/prx/libSceNKWebKit/src/HistoryItem.cppcore/libs/prx/libSceNKWebKit/tests/HistoryItem.cppdocs/dev/debt/changes/fix-libSceNKWebKit-history-item-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-27T22:46:11Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
ace9446d90:tools/check_conventions.pypassed.nkwebkit_historyitem_testsbuilt cleanly.nkwebkit_historyitem):core/libs/prx/libSceNKWebKit/src/HistoryItem.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:23Z.
Review: COMMENTED
Actionable comments posted: 2
b51edd30-181e-40d2-a55c-038be12d1c92Reviewing files that changed from the base of the PR and between
2621a4ad6dandace9446d90.core/libs/prx/libSceNKWebKit/src/HistoryItem.cppcore/libs/prx/libSceNKWebKit/tests/HistoryItem.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-11-28T05:39:27Z.
Review: APPROVED
Checked head
ace9446d90. All on Windows 11 with WinLibs GCC 15.2 (Release), applied tomain4c7578e0a4together with #27997, #27996, #27978, #27975, #27973, #27971, #27969, #27967, #27964, #27958, #27949, #27946, #27945, #27943, #27938, #27936.tools/check_conventions.py --headandtools/debt_fold.py --checkpassed and the full build succeeded.nkwebkit_historyitempasses. 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:16:58Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: prevent
PlanReleasefrom decrementing a zero refcount and wrapping it to a large value.What I ran
Reviewed head
ace9446d9030091c3af98a287abb06ab21aa677against the prepared diff. I did not run commands or tests. The author reports Linux Release test and convention checks indescription.md; these were not independently run.Results
Findings
Blocking
core/libs/prx/libSceNKWebKit/src/HistoryItem.cpp:145: When aStringImplrefcount is zero, this branch subtracts two from an unsigned value, wrapping it to a very large count. The intended validation inPlanReleaserejects destroyed strings and terminal ownership flags but does not reject an invalid count before decrementing. This can occur while replacing a field or assigning document state with malformed guest string state; reject counts below two before the subtraction.Non-blocking
None.
Not verified
Tests, build, console behavior, and unreviewed change lines were not verified. Read:
description.md,commits.md,manifest.json,README.md, the full changed sourceHistoryItem.cpp, the changed debt fragment, and selected ranges ofdiff.patchand test sourceHistoryItem.cpp. The test source was not read in full; no claim is made about its unread lines. No changed files were excluded according to the review folder listing.To get this to a good state
Reject a
StringImplrefcount below two before decrementing inPlanRelease, then rerun the reportednkwebkit_historyitemandnkwebkit_historyitemurltests and review the updated head.Imported from boykopovar/AnyPS5. Originally posted by NobleBrains on 2026-12-01T00:22:07Z.
Review: APPROVED
Confirmed on macOS 15.
Setup: Apple M4, macOS 15.7.9, Apple clang 17.0.0 (clang-1700.6.3.2), x86_64 Release under Rosetta,
BUILD_TESTING=ON. These are the OS and compiler generation of themacos-15runner.Tree:
main93d64f2d1e+ the open macOS build fixes #27201, #27739, #27843, #17425, #27827, #27767 (maindoes not build on macOS without them, see #28168), + #22091, #28369, #28075, #28076, #28284, then #17878, #20161, #25134, #26806, #22932, #28373, #27828, #27950, #27582, #24311 merged one after another. All merged cleanly.nkwebkit_historyitemace9446d90Full
ctest -j 6after all of them: 7047/7066 pass. Compared with the run before the second group of merges, no test fails that passed before.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T08:12:46Z.
Review: COMMENTED
The HistoryItem fixture covered protected item objects and rejected state and form-data references. It confirmed the caller’s reference stayed intact when an update was rejected.
I ran the exact fixture and changed translation unit in a focused Linux build linked against the project’s guest libraries.
AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.