feat(libSceNpTus): check the arguments of 82 TUS and TSS requests and fail them signed out #9009
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9009"
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 YossiYad on 2026-10-21T09:39:27Z.
What
libSceNpTus already models TUS offline: an asynchronous call checks its arguments, then
StartOfflinemarks the request started and it finishes withSCE_NP_ERROR_SIGNED_OUT; the synchronous form waits for it throughComplete. 82 more calls of the library threw. They now do the same:A), virtual-user (VUser) and cross-save forms.sceNpTssGetSmallStorageAsyncandsceNpTssGetSmallStorage.Each asynchronous call runs the argument checks of shadPS4 in shadPS4's order, from its signature up to the point where shadPS4 resolves the request: null and missing arguments are
INSUFFICIENT_ARGUMENT, a non-null option, a negative slot and an empty virtual user areINVALID_ARGUMENT, more than 64 slots isTOO_MANY_SLOTID, more than 101 users or 100 friends isTOO_MANY_NPID, an operation type outside 1-6 isINVALID_TYPE, and a TSS size above 64 KiB isINVALID_ARGUMENT. shadPS4's differences between forms are kept, and the debt entry names them: its NpId try-and-set calls returnINVALID_ARGUMENTfor a bad operation type, and its NpId and virtual-user multi-slot data status calls returnTOO_MANY_NPIDfor too many slots. As for the multi-slot variable calls already here, output and structure sizes are not checked and no output is written, since their layouts are not verified.Left out: the
Aand cross-save friends calls andsceNpTssGetDataAsync, whose shadPS4 checks read fields of an option structure whose layout is not known here, with their synchronous forms; the five calls shadPS4 does not implement; and the calls shadPS4 only stubs. None of the new results is measured on a PS5; the debt entry says so, and the 82 "unknown signature" lines are removed.Tested
Linux (Fedora 44, GCC, Ninja,
-DBUILD_TESTING=ON), based onmain27c88a8d75:guest_np_tus_offline(core/libs/tests/GuestNpTusOffline.cpp): every one of the 43 asynchronous calls starts with valid arguments and its request finishes with0x80550006, refuses an unknown request withINVALID_IDand a non-null option withINVALID_ARGUMENT; every one of the 39 synchronous calls returns0x80550006. Targeted cases cover an empty virtual user (alone and inside an array), operation types 0 and 7 (INVALID_TYPE, andINVALID_ARGUMENTfor the NpId form), a negative slot, 65 slots, 102 users, 101 friends, sort type 5 and a TSS size of 64 KiB + 1. It aborts onmain'sExport.cpp, and fails when one call drops its option check or one synchronous call returns 0.guest_np_tuspasses on every commit.ctest: 1780 of 1788 pass. The 8 failures fail the same way onmainon this machine and do not link libSceNpTus:application_heap_scripting,application_heap_lazy,agc_driver_guest_memory_lifetime,agc_driver_image_array_window_past_layer_limit,agc_driver_tessellationand the threenet_dontwait_blocking_*cases.tools/progress.py --compare: libraries +0.93%, 82 functions implemented, none lost.tools/check_conventions.py --base upstream/mainpasses on every commit.tools/pr_overlap.pyfinds no overlap; it could not compareExport.cppwith #6977, which conflicts withmain, and #6977's NpTus additions are other functions.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 github-actions[bot] on 2026-10-21T09:40:18Z.
Progress report (
b5d7637→1f407e5)📈 System libraries: 51.9% (+0.93%, +82 implemented functions)
✅ 82 implemented
sceNpTssGetSmallStoragesceNpTssGetSmallStorageAsyncsceNpTusAddAndGetVariablesceNpTusAddAndGetVariableAsceNpTusAddAndGetVariableAVUsersceNpTusAddAndGetVariableAVUserAsyncsceNpTusAddAndGetVariableAsyncsceNpTusAddAndGetVariableForCrossSavesceNpTusAddAndGetVariableForCrossSaveAsyncsceNpTusAddAndGetVariableForCrossSaveVUsersceNpTusAddAndGetVariableForCrossSaveVUserAsyncsceNpTusAddAndGetVariableVUsersceNpTusAddAndGetVariableVUserAsyncsceNpTusDeleteMultiSlotDatasceNpTusDeleteMultiSlotDataAsceNpTusDeleteMultiSlotDataAAsyncsceNpTusDeleteMultiSlotDataAsyncsceNpTusGetDataAsceNpTusGetDataAAsyncsceNpTusGetDataAVUsersceNpTusGetDataAVUserAsyncsceNpTusGetDataAsyncsceNpTusGetDataForCrossSavesceNpTusGetDataForCrossSaveAsyncsceNpTusGetDataVUserAsyncsceNpTusGetFriendsDataStatussceNpTusGetFriendsDataStatusAsyncsceNpTusGetFriendsVariablesceNpTusGetFriendsVariableAsyncsceNpTusGetMultiSlotDataStatussceNpTusGetMultiSlotDataStatusAsceNpTusGetMultiSlotDataStatusAAsyncsceNpTusGetMultiSlotDataStatusAVUsersceNpTusGetMultiSlotDataStatusAVUserAsyncsceNpTusGetMultiSlotDataStatusAsyncsceNpTusGetMultiSlotDataStatusForCrossSavesceNpTusGetMultiSlotDataStatusForCrossSaveAsyncsceNpTusGetMultiSlotDataStatusForCrossSaveVUsersceNpTusGetMultiSlotDataStatusForCrossSaveVUserAsyncsceNpTusGetMultiSlotDataStatusVUsersceNpTusGetMultiSlotDataStatusVUserAsyncsceNpTusGetMultiUserDataStatussceNpTusGetMultiUserDataStatusAsceNpTusGetMultiUserDataStatusAAsyncsceNpTusGetMultiUserDataStatusAVUsersceNpTusGetMultiUserDataStatusAVUserAsyncsceNpTusGetMultiUserDataStatusAsyncsceNpTusGetMultiUserDataStatusForCrossSavesceNpTusGetMultiUserDataStatusForCrossSaveAsyncsceNpTusGetMultiUserDataStatusForCrossSaveVUsersceNpTusGetMultiUserDataStatusForCrossSaveVUserAsyncsceNpTusGetMultiUserDataStatusVUsersceNpTusGetMultiUserDataStatusVUserAsyncsceNpTusGetMultiUserVariablesceNpTusGetMultiUserVariableAsceNpTusGetMultiUserVariableAAsyncsceNpTusGetMultiUserVariableAVUsersceNpTusGetMultiUserVariableAVUserAsyncsceNpTusGetMultiUserVariableAsyncsceNpTusGetMultiUserVariableForCrossSaveAsyncsceNpTusGetMultiUserVariableForCrossSaveVUsersceNpTusGetMultiUserVariableForCrossSaveVUserAsyncsceNpTusGetMultiUserVariableVUsersceNpTusGetMultiUserVariableVUserAsyncsceNpTusSetDataAsceNpTusSetDataAAsyncsceNpTusSetDataAVUsersceNpTusSetDataAVUserAsyncsceNpTusSetDataAsyncsceNpTusSetDataVUserAsyncsceNpTusTryAndSetVariablesceNpTusTryAndSetVariableAsceNpTusTryAndSetVariableAAsyncsceNpTusTryAndSetVariableAVUsersceNpTusTryAndSetVariableAVUserAsyncsceNpTusTryAndSetVariableAsyncsceNpTusTryAndSetVariableForCrossSavesceNpTusTryAndSetVariableForCrossSaveAsyncsceNpTusTryAndSetVariableForCrossSaveVUsersceNpTusTryAndSetVariableForCrossSaveVUserAsyncsceNpTusTryAndSetVariableVUsersceNpTusTryAndSetVariableVUserAsyncImported from boykopovar/AnyPS5. Originally posted by clairtonmichel on 2026-10-21T09:51:46Z.
Tested on AMD Ryzen 7 9800X3D and AMD Radeon RX 7900 XTX (Fedora Linux, Mesa 26.2.5):
guest_np_tus_offline, trophy data, web APIs, etc.): 100% passed successfully (55/55 green in 2.03s).Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T09:53:12Z.
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.
main)core/libs/prx/libSceNpTus/Export.cppL13-14, L345-347, L350-352, L355-357, L360-362, L745-747, L750-752, L755-757, L760-762, L765-767, L770-772, L775-777, L780-782docs/dev/debt/libSceNpTus.mdL5-6, L13-27, L97-110sceNpTusTryAndSetVariablesceNpTusTryAndSetVariableAsceNpTusTryAndSetVariableAAsyncsceNpTusTryAndSetVariableAVUsersceNpTusTryAndSetVariableAVUserAsyncsceNpTusTryAndSetVariableAsyncsceNpTusTryAndSetVariableForCrossSavesceNpTusTryAndSetVariableForCrossSaveAsyncsceNpTusTryAndSetVariableForCrossSaveVUsersceNpTusTryAndSetVariableForCrossSaveVUserAsyncsceNpTusTryAndSetVariableVUsersceNpTusTryAndSetVariableVUserAsyncImported from boykopovar/AnyPS5. Originally posted by pipe1os on 2026-10-21T14:48:28Z.
Ran this on Windows, since the only run so far was on Linux.
Windows 11 Pro 26300, WinLibs GCC 15.2.0, Ninja, Release,
BUILD_TESTING=ON.1f407e5merged onto main2c4b116without conflicts.ctest --test-dir build -R '^guest_np_tus':guest_np_tusandguest_np_tus_offlineboth pass.core/libs/prx/libSceNpTus/Export.cppreverted to main,guest_np_tus_offlinefails with0xc0000409andsceNpTssGetSmallStorageAsync not implemented. All 82 newly implemented functions are called in the test.libSceNpTus.prxexports the same 136 NIDs as main's.tools/check_conventions.py --base origin/mainpasses.I also compared the order of the error returns in all 82 against shadPS4 a808e76 (
np_tus.cppis identical at c1b2655 and at shadPS4's current tip). They match everywhere except theINVALID_ALIGNMENTsize checks, which the debt entry already lists as skipped. That includes the try-and-setopeTypesplit and the friendssortTyperanges.Heads up: #8925 (mine, opened a few hours before this one) does the 12
sceNpTusTryAndSetVariable*calls with the same checks, so whichever lands first leaves the other conflicting. If this one goes in, I'll close mine.Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T15:14:06Z.
Independent Windows run of this PR (data only).
Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against
mainis clean. I built onlyguest_np_tus_offline_tests;ctest -N -R guest_np_tus_offlinelists exactly one test.PR head tested:
1f407e5970411881fc20f14835df729c721693c1.Results (3 runs each):
guest_np_tus_offlinepasses 3/3.core/libs/prx/libSceNpTus/Export.cppwith the version from the PR's merge base (27c88a8d75), then rebuilt. The test fails 3/3 (exit 0xc0000409). I restored the PR's files afterwards.GPU: the run output has no
Selected GPUline; no GPU claim is made.Not run: other platforms, the other tests in the same family, the full repository CTest, and any title or console run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-21T19:43:21Z.
Thanks @clairtonmichel for the Linux run, and @pipe1os and @xXPBSXx for the Windows ones. The baseline runs with
Export.cppreverted are the useful part, since they show the test actually reaches the new code.@pipe1os you're right about #8925, and yours was opened first. If it lands before this one I'll rebase on it and drop my 12
sceNpTusTryAndSetVariable*calls, so you don't need to close anything. Thanks also for checking the error order againstnp_tus.cpp.Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-22T05:34:44Z.
@oneandonlydean @adriadam10 ready from my side: CI is green and it has one Linux and two Windows runs, with the test failing on
main'sExport.cpp. It overlaps pipe1os's #8925 on the 12sceNpTusTryAndSetVariable*calls; either order works, and if #8925 goes first I'll rebase this one onto it.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-22T05:37:53Z.
@YossiYad thanks, it's in my review queue now. I'll come back here with the result.