fix(libSceNKWebKit): validate guest pointers in SQLite exports #27971
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27971"
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-27T23:34:27Z.
What
Validate guest memory reads and writes across all 59
WebCore::SQLiteDatabase,WebCore::SQLiteStatement,WebCore::SQLiteTransaction, andWebCore::SQLiteStatementAutoResetScopeexports incore/libs/prx/libSceNKWebKit/src/SQLite.cpp:GuestArena::HostWritescopes (GuestWriteScope/GuestWriteRef) checkingGuestWritable_nid_no_patch(andGuestArenaPrepareHostRead_nid_no_patch+GuestReadable_nid_no_patchfor read-modify-write paths), while preserving existing null-argumentstd::invalid_argumentbehavior.String*,StringImpl*, andStringImpl::datareadability before allocating hoststd::u16stringcopies (CopyGuestString/CopyGuestStringImpl) and copy viaGuestCopyIn_nid_no_patch.blobbuffers inSQLiteStatement::bindBlob,SQLValue*inbindValue,CollationFunction*/CollationCallable*/ vtable slots insetCollationFunction, andWTF::Vector<char>/WTF::Vector<unsigned char>headers and reused buffers ingetColumnBlobAsVector.GuestCopyIn_nid_no_patch/GuestCopyOut_nid_no_patchwith rollback inSQLiteStatementAutoResetScopemove construction and move assignment, and eliminate directself->~SQLiteDatabase()dereferences inSQLiteDatabase::~SQLiteDatabase.core/libs/prx/libSceNKWebKit/tests/SQLiteDatabase.cppand record the unmeasured console fault behavior indocs/dev/debt/changes/fix-libSceNKWebKit-sqlite-guest-pointers.md.Tested
CheckGuestPointerstests inSQLiteDatabase.cppagainst unmodifiedSQLite.cpp):nkwebkit_sqlitedatabasefailed with***Exception: SegFault(0/1 passed).nkwebkit_sqlitedatabase_tests;ctest -R '^nkwebkit_sqlitedatabase$'passed (1/1,0.04 sec).python3 tools/guest_pointer_audit.py libSceNKWebKitreports 0 direct guest pointer accesses insrc/SQLite.cpp.python3 tools/check_conventions.py --base origin/mainpassed.python3 tools/pr_overlap.py --branch fix/libSceNKWebKit-sqlite-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-27T23:42:45Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
ee0fc0f1ff:tools/check_conventions.pypassed.nkwebkit_sqlitedatabase_testsbuilt cleanly.nkwebkit_sqlitedatabase):core/libs/prx/libSceNKWebKit/src/SQLite.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:44:44Z.
Review: COMMENTED
Actionable comments posted: 8
337d239e-4b66-4259-8bcb-434daeddf6f3Reviewing files that changed from the base of the PR and between
a2d8d409dbandee0fc0f1ff.core/libs/prx/libSceNKWebKit/src/SQLite.cppcore/libs/prx/libSceNKWebKit/tests/SQLiteDatabase.cppdocs/dev/debt/changes/fix-libSceNKWebKit-sqlite-guest-pointers.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-27T23:51:16Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
983a557113:tools/check_conventions.pypassed.nkwebkit_sqlitedatabase_testsbuilt cleanly.nkwebkit_sqlitedatabase):core/libs/prx/libSceNKWebKit/src/SQLite.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 Plyxen on 2026-11-28T05:39:14Z.
Review: APPROVED
Checked head
983a557113. All on Windows 11 with WinLibs GCC 15.2 (Release), applied tomain4c7578e0a4together with #27997, #27996, #27978, #27975, #27973, #27969, #27967, #27964, #27958, #27950, #27949, #27946, #27945, #27943, #27938, #27936.tools/check_conventions.py --headandtools/debt_fold.py --checkpassed and the full build succeeded.nkwebkit_sqlitedatabasepasses. 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:23:15Z.
Review: COMMENTED
Reviewed — comments
Nothing blocks this review, but some validation checks were not run and a guest database pointer is not validated when a statement is constructed.
What I ran
Reviewed head
983a557113c6a65e5116683b5dac908ab3fe335f. Read the prepared description, commits, manifest, full diff, changed source around the pointer helpers and blob/vector handling, the changed test section, and the new debt note. No commands or tests were run;repo_read.pywas unavailable in this environment.Results
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceNKWebKit/src/SQLite.cpp:466-469:ConstructStatementchecks thatdbis non-null but does not validate that the pointed-toSQLiteDatabaseobject is readable. A non-null invalid guest address can therefore be stored in the constructed statement and fail only when a later operation accesses it. Consider validating the database object before storing the pointer.Not verified
Tests and reported audit/convention checks were not rerun. Console fault behavior is documented as unmeasured. The full changed-file text was not read line by line; the diff was read, and targeted head ranges were inspected for the behavior above. The prepared file listing included all three changed files; no excluded-file listing was available.
To get this to a good state
Nothing is required. Optional: validate the database pointer during statement construction and rerun the reported checks on the updated head.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T08:12:40Z.
Review: COMMENTED
The SQLite fixture covered both normal database operations and rejection of invalid database, transaction and statement-scope objects. The move and destructor rejection cases passed.
I ran the exact fixture and changed translation unit in a focused Linux build linked against the project’s guest libraries.
AI-assisted: yes.