Repository navigation
fix(libScePad): check scePadInit and pointers before the handle as a PS5 does - #11558
Closed
hugodearaujo wants to merge 1 commit into
Closed
hugodearaujo wants to merge 1 commit into
hugodearaujo wants to merge 1 commit into
Conversation
|
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.
|
Contributor
Author
|
Closing this: I noticed the evidence for it is weak. The measurements are right, but none of the titles I have reaches the error paths it changes (they all call |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
On a PS5, these ScePad calls check that
scePadInitran, then their pointer arguments, then the handle. AnyPS5 checked the handle first, had no initialization check in them and wrote nothing on a bad handle. They now follow the measured order:scePadInit:NOT_INITIALIZED(0x80920005), even with a null pointer, exceptscePadReadState(h, NULL), which isINVALID_ARG(0x80920001).scePadReada count outside 1 to 64, isINVALID_ARGbefore the handle is looked at; a bad handle is thenINVALID_HANDLE(0x80920003).scePadReadStatewrites the 120-byte rest record (buttons 0, sticks 0x80, orientation (0, 0, 0, 1), acceleration (0, 1, 0), everything else zero, padding included) both beforescePadInitand on a bad handle. On a bad handle,scePadDeviceClassGetExtendedInformationwrites 20 zero bytes andscePadDeviceClassParseDatawrites 24 bytes, a device class of -1 and zeros. The other calls write nothing.The calls, with how many of the nine converted titles I have import each:
scePadGetControllerInformation(9),scePadSetTriggerEffect(8),scePadReadState,scePadSetLightBar,scePadResetLightBarandscePadSetVibration(6 each),scePadRead(4),scePadResetOrientation(3),scePadSetTiltCorrectionState,scePadSetAngularVelocityDeadbandStateandscePadIsRemoteController(2 each),scePadSetMotionSensorState,scePadDeviceClassGetExtendedInformationandscePadDeviceClassParseData(1 each).scePadOpen,scePadOpenExt,scePadGetHandle,scePadClose,scePadGetTriggerEffectStateandscePadGetExtControllerInformationfollow the same rule on the console but are left out, because #10935, #5038, #10112 and #11187 change them. With the initialization check in front,scePadReadandscePadReadStateno longer reach the "read before initialization" throws inPadState.cpp.Measured
PS5 on firmware 13.60, from a payload process, calling the exports of
libScePad.sprxthroughdlopenanddlsym. The bad handles 0, 1, -1 and 0x7fffffff gave the same results. Lines from the probe logs (phase, call, handle, result, bytes written, bytes):Before
scePadInit, each of the fourteen calls returned 0x80920005, also with null pointers and with counts of 0, -1 and 65, and none of them wrote anything exceptscePadReadState.scePadReadState(h, NULL)returned 0x80920001, andscePadInittwice returned 0 both times.Tested
mainafc780e:guest_padandguest_pad_vibration_modepass, 3 of 3 runs. The newCheckBeforeInitruns beforescePadInit, andCheckBadHandleArgumentschecks the codes and records for the four bad handles and the 64-record limit on a real handle. Withmain'sExport.cppand the new tests,guest_padaborts.tools/check_conventions.pypasses.tools/pr_overlap.pylists neighbouring test lines inGuestPad.cppwith fix(pad): timestamp fresh controller samples when read #6337 and feat(libScePad): implement scePadIsValidHandle, the light-bar resets and scePadSetVibrationForce #10880.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)