Repository navigation
fix(libSceUserService): refuse sceUserServiceGetNpAccountId before initialization - #23549
Conversation
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 719cdb5505:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_np_manager_tests,guest_user_service_account_name_limits_tests,guest_user_service_age_level_guest_bounds_tests,guest_user_service_kratos_tests,guest_user_service_profiles_bounds_tests,guest_user_service_testsbuilt cleanly. - CTest (
guest_np_manager,guest_user_service,guest_user_service_kratos,guest_user_service_profiles_bounds,guest_user_service_account_name_limits,guest_user_service_age_level_guest_bounds):1/6 Test #4860: guest_np_manager ............................ Passed 0.01 sec 2/6 Test #5196: guest_user_service .......................... Passed 0.01 sec 3/6 Test #5202: guest_user_service_profiles_bounds .......... Passed 0.01 sec 4/6 Test #5201: guest_user_service_kratos ................... Passed 0.01 sec 5/6 Test #5205: guest_user_service_account_name_limits ...... Passed 0.01 sec 6/6 Test #5206: guest_user_service_age_level_guest_bounds ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 6 - Negative control: with
core/libs/prx/libSceUserService/Export.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/6 Test #4860: guest_np_manager ............................ Passed 0.01 sec 2/6 Test #5196: guest_user_service ..........................Subprocess aborted***Exception: 0.17 sec 3/6 Test #5202: guest_user_service_profiles_bounds ..........Subprocess aborted***Exception: 0.19 sec 4/6 Test #5201: guest_user_service_kratos ...................Subprocess aborted***Exception: 0.20 sec 5/6 Test #5205: guest_user_service_account_name_limits ......Subprocess aborted***Exception: 0.22 sec 6/6 Test #5206: guest_user_service_age_level_guest_bounds ...Subprocess aborted***Exception: 0.18 sec 17% tests passed, 5 tests failed out of 6 - Code reading:
- Verified Export.cpp:sceUserServiceGetNpAccountId checks initialized.load() before null check (account_id == nullptr) and user bounds, returning USER_SERVICE_ERROR_NOT_INITIALIZED (0x80960002) as verified against PS5 FW 13.42 module disassembly and PS4 Pro FW 10.71 console behavior.
- Verified docs/dev/debt/changes/fix-userservice-np-account-not-initialized.md follows debt fragment specifications and properly documents the behavior change.
- Verified CMakeLists.txt links libSceUserService to guest_np_manager_tests to satisfy the sceUserServiceInitialize dependency in CheckValueClasses.
- Verified GuestUserService.cpp and other test suites (GuestUserServiceAccountNameLimits, GuestUserServiceAgeLevelGuestBounds, GuestUserServiceKratos, GuestUserServiceProfilesBounds) accurately verify the pre-initialization gate and untouched output buffer on error.
Looks Good To Me
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — comments
Nothing blocks this; the points below are optional.
What I ran
Reviewed head 719cdb5505fe7a95ec1cab9c03dc85438fa52533 using repo_read.py to inspect the prepared diff and changed code ranges. No test or build commands were run; this environment provided reader-only access.
Results
| Check | Result | Note |
|---|---|---|
| Changed code review | passed | All nine changed files’ relevant hunks were read |
| Focused tests and checks | not run | Author reports passing results; not independently verified |
Findings
Blocking
None.
Non-blocking
None.
Not verified
The reported Windows 11 focused ctests, debt check, and conventions check were not run during this review. No changed files were excluded by the manifest; the review folder’s files.json was unavailable through the reader.
To get this to a good state
Nothing is required. Optionally, run the reported focused ctests and checks on this head before relying on their results independently.
719cdb5 to
ce92d61
Compare
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
The initialization gate and its validation order match the PR description; I did not run the reported checks, and the review is incomplete because I did not read every changed file in full.
What I ran
Inspected the prepared diff and selected code at head ce92d6134f85c2eecf855c4f263db850b2a31437 using repo_read.py. No checks were run.
Results
| Check | Result | Note |
|---|---|---|
| Diff and targeted code inspection | passed | Gate precedes output and user checks |
| Reported tests and conventions checks | not run | Reported by the author only |
| Full changed-file review | not run | Several changed files were only partly read |
Findings
Blocking
None identified in the code inspected.
Non-blocking
None.
Not verified
The manifest lists 9 changed files, all included in the prepared folder. I read selected ranges from core/libs/prx/libSceUserService/Export.cpp, core/libs/tests/GuestUserService.cpp, core/libs/tests/GuestUserServiceProfilesBounds.cpp, core/libs/tests/GuestUserServiceAccountNameLimits.cpp, core/libs/tests/GuestNpManager.cpp, and core/libs/prx/libSceNpManager/CMakeLists.txt; these were not all read in full. I did not read core/libs/tests/GuestUserServiceAgeLevelGuestBounds.cpp, core/libs/tests/GuestUserServiceKratos.cpp, or docs/dev/debt/changes/fix-userservice-np-account-not-initialized.md. No tests were run, and behavior on a PS5 was not verified. The author reports 15 focused ctests and two repository checks passed on Windows 11.
To get this to a good state
Nothing is required. Optional: complete the changed-file review and run the reported checks on this head before making a formal approval decision.
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Windows run of ce92d61, merged onto main 2b0d3ee (merge 9d63f96929). The merge is clean and the merged Host: Ryzen 9 9950X3D, Windows 11 Pro 26300, WinLibs GCC 15.2, Ninja, Release. Tests: the 15 focused ctests from the PR description ( Existing runs:
This run adds the Windows negative control, mutations, and a probe of the libSceNpManager callers before initialization. Results
This matches PrivacyOnion's Linux control. Mutations (on the merge, one at a time)
The tests pin the order (gate, then null output, then user) and the untouched output. The CMake change and the new initialize call are both needed. Probe:
|
| Call | main's Export.cpp |
merge |
|---|---|---|
IsLoggedIn |
true | false |
GetAccountId |
0x80559e2b (account id missing), output 0 | 0x80960002, output 0 |
HasAccountId |
0, output false | 0x80960002, output untouched |
GetAccountIdFromRegistory |
0, output 0 | 0x80960002, output untouched |
So in a process that never initializes the user service, these NP value-class calls now fail with the user service's 0x80960002. The PR description says this is intended. Two notes:
- No test pins these four answers before initialization.
GetAccountIdwrites 0 to its output before it calls the user service (mainValueClasses.cpp251). So its output is 0 on this failure, while the other two leave theirs untouched. This was already the case on main, where the failure only happened for unknown users.
Whether firmware's sce::np::User passes the user service code through like this is not measured. A line in the libSceNpManager debt entry, or asserts in CheckValueClasses before line 918, would record it.
AI-assisted: yes
What
sceUserServiceGetNpAccountIdnow returnsUSER_SERVICE_ERROR_NOT_INITIALIZED(0x80960002) before its null-output and login checks, following the order of firmware 13.42's handler (0x3e10): the module checks its IPMI client variable first and answers0x80960002while it is not initialized, then0x80960005for a null output, before it looks at the user (disassembly and a native run of the module with stubbed imports, not measured on a console; the PS4 Pro 10.71 run in the same thread also answered0x80960002aftersceUserServiceTerminate).sceUserServiceInitializeandsceUserServiceTerminatealready maintain theinitializedstate, so the gate is one check at the top of the export. The debt entry is updated by fragment to record that both module gates are modelled.sce::np::User's account lookups in libSceNpManager call this export and now answerUSER_SERVICE_ERROR_NOT_INITIALIZEDin a process that never initialized the user service;CheckValueClassesinitializes it, as a title does, so the logged-in and missing-account answers stay covered, and the other guest tests cover the not-initialized answers, including the untouched output.Shared files with open PRs, none implementing this export: #12860 and #12900 also add pre-initialization assertions and an
sceUserServiceInitializecall at the top ofGuestUserService.cpp'smainforGetForegroundUser,GetUserNameandGetInitialUser; #9345, #9828 and #14829 touch otherlibSceUserServiceexports. Whichever of #12860 or #12900 merges first, the rebase folds their and this branch's pre-initialization assertions into one block with a singlesceUserServiceInitializecall; the debt entries are distinct, so the fragments do not collide.Tested
Windows 11, WinLibs GCC 15.2.0 (
x86_64-ucrt-posix-sehr7), Ninja, Release,BUILD_TESTING=ON. All 15 focused ctests pass:guest_user_service,guest_user_service_group_io,guest_user_service_user_name,guest_user_service_user_kind,guest_user_service_shell_core,guest_user_service_lifecycle,guest_user_service_kratos,guest_user_service_profiles_bounds,guest_user_service_multi_login_event_bounds,guest_user_service_login_list,guest_user_service_account_name_limits,guest_user_service_age_level_guest_bounds,guest_np_manager,guest_np_reachability,guest_np_asm_client_ext.python tools/debt_fold.py --checkandpython tools/check_conventions.py --base origin/mainpass with no findings. Not tested on a PS5.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)