fix(libSceSystemService): read guest title ID safely via GuestCopyIn #24962
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24962"
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 nexus1692 on 2026-11-21T13:16:51Z.
What
sceSystemServiceGetAppIdandsceLncUtilIsAppLaunchedread their title ID withstd::strlenand astd::stringconstruction straight from the guest pointer (WellFormedTitleId). A non-null pointer that the process cannot read, or a string with no terminator within the 10-byte title ID buffer, therefore crashed the host instead of getting the documented answer. The other direction in the same file is already guarded: an unwritable title-ID buffer throws a host-safety rejection.This replaces the helper with
ReadTitleId, which reads one byte at a time throughGuestCopyIn_nid_no_patch, stops at the terminator and never reads pastTitleIdBufferSize, preserving the caller'serrno. An unreadable pointer is answered as a malformed title ID:-1fromsceSystemServiceGetAppIdand0x80940005fromsceLncUtilIsAppLaunched.sceLncUtilIsAppLaunchedstill passes its own guest pointer on tosceSystemServiceGetAppId. The running-title answer, the-1for a title ID whose length is not 9 and the throw for another title are unchanged, and no error code was added. Both are recorded indocs/dev/debt/libSceSystemService.mdthrough the fragment.docs/dev/debt/libSceSystemService.mdalready records the same class of fallback for the output buffer; the firmware reads the pointer unchecked and faults on it, which is not measured on a console.Note: #14202 changes the rejection in
RunningAppIdon the same line, so one of the two needs a rebase.Tested
Windows 11, x86-64 MinGW-w64 GCC 16.2.0, host-only change; no console run.
ninja -k 0 -C buildlibSceSystemService.prxpatched andguest_system_service_app_title_id_tests.exelinkedctest --test-dir build -R "app_title_id" --output-on-failurectest --test-dir build -R "guest_system_service|lnc" --output-on-failurepython tools/check_conventions.py --base origin/mainpython tools/pr_overlap.py --names sceSystemServiceGetAppId,sceLncUtilGetAppId,sceLncUtilIsAppLaunchedpython tools/pr_overlap.py --branch fix/systemservice-title-id-guest-readThe new case passes an unreadable title ID (
0x10) and requires-1from bothsceSystemServiceGetAppIdandsceLncUtilGetAppId,0x80940005fromsceLncUtilIsAppLaunched, and the caller'serrnounchanged. The valid-title path (sceLncUtilIsAppLaunchedwith the running title) is covered by the existing checks, which still pass.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 MarcZX10 on 2026-11-21T13:49:15Z.
Review: APPROVED
Reviewed — looks good
The changed title ID reads are bounded and use guarded guest copies; no blocking defect was found in the reviewed code.
What I ran
Reviewed head
712cae54768e9761c43190e92694096d3a36347dusingrepo_read.pyto inspect the prepared diff, changed files, and targeted repository context. No build or tests were run; the checks in the PR description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests or build were run during this review.
core/libs/prx/libSceSystemService/Export.cpp,core/libs/tests/GuestSystemServiceAppTitleId.cpp, anddocs/dev/debt/changes/fix-systemservice-title-id-guest-read.mdwere read; all three changed files listed in the manifest were reviewed. Other repository files and physical console behavior were not verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T14:09:59Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
712cae5476:tools/check_conventions.pypassed.guest_system_service_app_title_id_testsbuilt cleanly.guest_system_service_app_title_id_known,guest_system_service_app_title_id_long,guest_system_service_app_title_id_missing):core/libs/prx/libSceSystemService/Export.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me