fix(libSceIcu): read hashed strings through guest copies #24383
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24383"
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 Bladureau on 2026-11-20T15:32:57Z.
What
ustr_hashUCharsN,ustr_hashCharsNandustr_hashICharsNpassed guest pointers straight to bundled ICU 78.1, so an unreadable string crashed the host instead of throwing.ICU's
STRING_HASH(ustring.cpp, unchanged from 68.2) does not read the whole string: it samples everyinc = (length - 32) / 32 + 1-th unit, which is at most 63 units for any length (withlength = 32 + 32q + r,0 <= r < 32, that is32 + ceil(r / (q + 1))). Copying the whole range would read pages ICU never touches, so the wrappers copy only the sampled units throughGuestCopyIn_nid_no_patchand hash that array with the ICU function. For fewer than 64 units ICU's step is 1, so it hashes every copied unit in order and the value is unchanged.An unreadable sampled unit throws
std::invalid_argument, anderrnois preserved, as inuprv_strdup(586b9890a3). Null strings and nonpositive lengths still go to ICU, which reads nothing and returns 0.The existing
ustr_hash*checks intests/Availability.cppare kept; the newguest_icu_string_hashtest covers these exports on their own.Tested
Linux only (Ubuntu 24.04 container, GCC 13.3,
-Wall -Wextraclean): a minimal harness that builds the bundled ICUcommonsources with the project's definitions,StringHash.cppandtests/StringHash.cpp, withGuestCopyIn_nid_no_patchbacked byprocess_vm_readvon the own process. No full build and no Windows run, so theVirtualProtectbranch of the test is untested.StringHash.cppfrommainit crashes with SIGSEGV.STRING_HASHat lengths around every step change (31 to 97, 4095 to 4097, 131103/131104, up to 300000); null strings hash to 0 and nonpositive lengths read nothing; unreadable pointers throw and keeperrno; a 300000-unit string whose unsampled tail lies in aPROT_NONEpage hashes as in ICU, and shifting it by one unit so the last sample lands in that page throws.python tools/check_conventions.py --base upstream/mainandpython tools/debt_fold.py --checkpass.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
Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-20T15:33:09Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T16:01:21Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
8450b87ac9:tools/check_conventions.pypassed.guest_icu_string_hash_testsbuilt cleanly.guest_icu_string_hash):core/libs/prx/libSceIcu/StringHash.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 MarcZX10 on 2026-11-21T03:41:26Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the code read supports the reported sampled-copy behavior, and the author reports Linux harness coverage while Windows and the full build remain unverified.
What I ran
Reviewed head
8450b87ac9da4bec8da3f3cacc70311965b04f75. I readdescription.md,commits.md,manifest.json,diff.patch, and all four changed files listed as reviewed. I did not run build or tests; the Linux harness and convention checks are author-reported.Results
VirtualProtecttest branch unverifiedFindings
Blocking
None.
Non-blocking
None.
Not verified
No tests or build were run during this review. Windows behavior and the full project build were not verified. No changed files were excluded;
files.jsonwas not available in the review bundle.To get this to a good state
Nothing is required.