fix(libSceLibcInternal): copy _Mtxinit's name in through checked guest copies #23161
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23161"
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 milescoviello on 2026-11-18T19:32:39Z.
What
_Mtxinitlabels its mutexSceLibcI_<name>withsnprintf("%s", name), which read the caller's name through the guest pointer, so an unmapped name crashed the host.Changes:
MutexNameSize(32) bytes, all the label can use.CopyGuestString_nid_no_patch.GuestCopyIn_nid_no_patch, so it is still truncated as before.Labels for readable names, including truncated long ones, are unchanged.
Tested
Linux (Ubuntu 26.04.1, kernel 7.0), GCC 15.2, Ninja, Release,
-DBUILD_TESTING=ON:guest_libc_internal_mtxgains an unmapped (0x10) name:_Mtxinitreturns 1 and leaves the mutex handle null.guest_libc_internal_mtxpasses, 3 runs, ond3d109bb43, the pre-squash commit with this tree.main'sMutex.cppendsguest_libc_internal_mtxinfatal SIGSEGV (code 1) at address 0x0000000000000010.Windows 11 VM (GeForce GT 1030, WinLibs GCC 16.2.0 POSIX UCRT, Ninja, Release):
guest_libc_internal_mtxpasses, 3 runs, ond3d109bb43.mainwith only the new test (70360b8278) endsguest_libc_internal_mtxin an access violation (0xc0000005).Both:
git merge-treeagainstmain92231f2168is clean. No open PR editsMutex.cppor the test file.tools/check_conventions.pypasses on the branch and this body.tools/debt_fold.py --checkreports nothing for this fragment.2b04e8b990merged intomain(the whole ctest suite, WinLibs GCC 15.2.0, GitHub-hosted runners): on Windows Server 2025 all 6282 tests pass in both runs; on Windows Server 2022 the two runs have 4 and 3 failures out of 6282, and ycbuzi's report says 3 of the failing tests also fail onmainthere.2b04e8b990on an Apple M1 (macOS 26.5, Apple clang 21.0.0, x86_64 Release under Rosetta 2,main245210b07ewith #17425 and #11049 for the macOS build):guest_libc_internal_mtxpasses 3 of 3 with this PR, and 3 of 3 onmainwithmain's tests.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)Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-18T19:43:58Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
2b04e8b990:tools/check_conventions.pypassed.guest_libc_internal_mtx_testsbuilt cleanly.guest_libc_internal_mtx):core/libs/prx/libSceLibcInternal/Mutex.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-18T23:49:32Z.
Review: APPROVED
Reviewed — looks good
The checked copy handles unreadable names before mutex creation, and the 32-byte fallback preserves the previous truncation behavior at the reviewed head.
What I ran
Reviewed head
2b04e8b990de7dc693d5009ccff860c1e732d0f7. No commands or tests were run; the reported Linux/Windows runs and negative controls are author-reported only. The changed files listed in the manifest were all read:core/libs/prx/libSceLibcInternal/Mutex.cpp,core/libs/tests/GuestLibcInternalMtx.cpp, anddocs/dev/debt/changes/fix-libcinternal-mtxinit-name-guest-copy.md. Also read the relevant helper implementation incore/libs/prx/libc/src/General.cpp. No excluded-file inventory was available in the prepared review materials.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Builds, test execution, negative controls, merge preview, and physical-console behavior were not verified in this review. The author reports Linux and Windows test runs; those are not runs performed here.
To get this to a good state
Nothing is required.