Repository navigation
fix(libSceUserService): validate initialization and parameters in sceUserServiceGetForegroundUser - #12860
Conversation
|
@slopgobblercobbler thanks. Gating
|
483f451 to
2b64d41
Compare
|
Thank you for the review and observations. We have updated head
Ready for re-review. |
|
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 this head (
AI-assisted: yes (Claude Code). |
rooklz
left a comment
There was a problem hiding this comment.
Review of head 2b64d41451
The gate matches how main already handles sceUserServiceGetLoginUserIdList and sceUserServiceGetEvent: the not-initialized check comes before the null-pointer check, the error code is the same, and nothing is written. The test is a real regression guard. With main's Export.cpp it aborts at the first new row.
What I ran (macOS arm64, Apple clang, -fsanitize=address,undefined -fno-sanitize-recover=undefined)
- Standalone build of the PR's
libSceUserService/Export.cpp+GuestUserService.cpp.sceSystemServiceParamGetIntis stubbed and theANYPS5_LANGUAGEblock (lines 62-102) is cut, since it needs the real SystemService. Head: PASS.main'sExport.cpp: aborts at the newGetForegroundUser(nullptr) == NOT_INITIALIZEDrow. git merge-treevsupstream/mainbb04a4f1ea: clean.git diff --check: clean.check_conventions.py --base upstream/main --head: passed.- Overlap: #6584 only adds
sceUserServiceSetForegroundUseras a stub, and #9345 does not touch this function. Neither conflicts with this hunk.
Mutants (single edits to sceUserServiceGetForegroundUser)
| Mutant | Result |
|---|---|
| drop the initialized check | killed |
| null check before the initialized check | killed |
INVALID_ARGUMENT instead of NOT_INITIALIZED |
killed |
write *user_id before returning NOT_INITIALIZED |
survives |
The pre-initialization row only checks the return code. This optional row kills the survivor (4/4), and it passes on the head:
- Require(sceUserServiceGetForegroundUser(&foreground) == USER_SERVICE_ERROR_NOT_INITIALIZED);
+ Require(sceUserServiceGetForegroundUser(&foreground) == USER_SERVICE_ERROR_NOT_INITIALIZED && foreground == -1);Notes
- Debt wording. The entry says the result order "follows the other user-service getters". On this head, apart from this function, only 2 of the 23
sceUserServiceGet*exports check initialization:GetLoginUserIdListandGetEvent. The closest sibling,sceUserServiceGetInitialUser, still succeeds beforesceUserServiceInitialize. Suggested wording: "followssceUserServiceGetLoginUserIdListandsceUserServiceGetEventand is unmeasured". That keeps the entry accurate, and it records thatGetInitialUseris now the odd one out, which is a follow-up and not part of this PR. - Body is stale. The What and Tested sections still describe tests added in
GuestUserServicePs4.cpp. That file is not in the diff. Please drop those lines so the body matches the change. This partly answers @oneandonlydean's point 3. - On @oneandonlydean's point 2:
mainhas no implicitsceUserServiceInitializebefore the guest entry. The only in-tree caller outside the library islibSceHttpCache(Export.cpp:793). So a title that queries the foreground user before initializing now gets0x80960002instead of success. It would be good to say in the body whether you checked a title's startup order.
Non-blocking. Rows and notes are optional.
|
@slopgobblercob Console rows from a PS4 Pro (firmware 10.71): the system
AI-assisted: yes (Claude Code) |
|
@slopgobblercobbler thanks, the debt wording and the test rename are both what we asked for. One point is still open, and the hardware numbers that came in on this thread bear on it. The PS4 Pro probe above shows that the first Could you pick one of these and say which in the PR?
The probe did not try a null output pointer, so the null-before-initialize order can stay "unmeasured" in the debt entry. If you pick option 2, please add a case for the first We will also run one title boot on our side to check the startup order, and post the result here. |
|
Startup check on an RTX 4090 (Windows-independent, Linux build), main bb04a4f1 vs main + #12860 (2b64d41) vs main + #12900 (9493a76), one title boot each, cold shader cache:
So for these titles neither change alters startup. This doesn't settle what the getters return before |
2b64d41 to
d9d2d35
Compare
|
@oneandonlydean Thanks so much for running the title startup benchmark on the RTX 4090 and checking the import scan across the 25 titles! Really appreciate the verification that boot time (163 s) and logs remain identical to main with zero UserService errors. I've updated the Tested section in the description with your test results. |
d9d2d35 to
246317f
Compare
|
Rebased cleanly on latest upstream/main and updated the branch:
|
246317f to
2f4fc29
Compare
|
Rebased cleanly onto latest
|
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The change adds an initialization guard to sceUserServiceGetForegroundUser and updates its lifecycle test; the inspected implementation and test support the stated behavior.
What I ran
Reviewed head 606560926e1ccd17763bfb9943b7b36338a3ea72 from the prepared diff and read the changed implementation and test context with repo_read.py. No checks were run by me; reported checks below are from the PR description.
Results
| Check | Result | Note |
|---|---|---|
| Code review | passed | Changed behavior and lifecycle covered |
| Standalone test suite | not run | Reported by author |
| Conventions and registration checks | not run | Reported by author |
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
Did not run the standalone suite, conventions check, registration check, hardware/startup checks, or tests on other platforms. Read all changed files listed as reviewed: core/libs/prx/libSceUserService/Export.cpp, core/libs/tests/GuestUserService.cpp, and docs/dev/debt/libSceUserService.md. No files were excluded by the manifest.
To get this to a good state
Nothing is required.
|
@slopgobblercobbler closing this in favour of #25454 by olegon85, which answers the same question with a measurement: on a PS5 the six UserService getters return NOT_INITIALIZED (0x80960002) before Initialize, ahead of the pointer checks. #25454 follows that, and main's tests are being updated to match. This can reopen if a title process turns out to behave differently. |
What
libSceUserService/Export.cpp, validate initialization state before checking parameter pointers insceUserServiceGetForegroundUser, returningUSER_SERVICE_ERROR_NOT_INITIALIZEDwhen user service is not initialized andUSER_SERVICE_ERROR_INVALID_ARGUMENTwhen parameter pointers are null.GuestUserService.cppto verify foreground user behaviour before initialization and clean up on test completion.docs/dev/debt/libSceUserService.md.Tested
guest_user_servicestandalone test suite verifying parameter validation and uninitialized/initialized lifecycle transitions.GuestUserService.cppinitialization assertions.mainbb04a4f1vsmain+ fix(libSceUserService): validate initialization and parameters in sceUserServiceGetForegroundUser #12860 vsmain+ fix(libSceUserService): validate initialization and bounds in sceUserServiceGetUserName and sceUserServiceGetInitialUser #12900):NOT_INITIALIZEDorINVALID_ARGUMENTlines.sceUserServiceGetForegroundUserdirectly (all 25 importsceUserServiceGetInitialUser, 22 importsceUserServiceGetUserName).python tools/check_conventions.py --base upstream/main --head HEAD: 0 findings (All conventions checks passed).python tools/check_test_registration.py --scripts: passed (219 test scripts registered).Checklist
NotImplemented_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)