fix(libScePad): answer scePadOpen's user, index and port checks as measured on a PS5 #10361

Merged
orezraey merged 4 commits from upstream-pr/10361 into main 2026-10-24 23:44:16 +00:00
orezraey commented 2026-10-23 19:17:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orezraey on 2026-10-23T19:17:30Z.


What

scePadOpen's argument checks measured on a retail PS5 (firmware 13.60) through libScePad.sprx from a payload process. The sources and console logs are in this gist (ppad, ppad2). A payload process cannot open a port even for its logged-in user (it gets 0x809b0081, unknown user), so only the checks the console makes before that were reached.

The console:

  • fails port types 1, 5, 6, 16, 255 and -1 with INVALID_ARG (0x80920001) whatever the user, so the type is checked first;
  • lets types 0, 2, 3 and 4 through the type check;
  • fails user -1 with 0x809b0001 on types 0, 2, 3 and 4 and on index 1 (ppad, where the payload had no initial user), and index 1 of the standard port with 0x809b0003 for a logged-in user (ppad2).

AnyPS5 answered index 1 with INVALID_ARG, gave user -1 a handle, and failed types 3 and 4 with INVALID_ARG. It now answers user -1 and a non-zero index with the measured codes. Types 3 and 4 throw after the type and user checks, since the console accepts them and what they open is unknown; a title that probes them will stop here instead of getting a made-up error, which the new debt entry records.

Tested

Windows 11, MinGW (winlibs).

  • guest_pad checks user -1 on types 0, 2, 3 and 4 and on index 1, index 1 of a logged-in user and the invalid types. The pad tests pass three runs in a row.
  • At 199fd82e3d (main merged after its 4-controller pad change, which limits the standard port to logged-in users): scePadOpen checks the port type alone first, then user -1 and the index, and leaves the standard port's user lookup to PortForUser; libScePad.md keeps main's deadband, legacy haptics and controller information entries with this PR's scePadOpen entries. guest_pad and guest_pad_vibration_mode pass three runs in a row on Windows 11 (WinLibs GCC 15.2) and on Linux (WSL2, GCC 16.2); a plain merge without the type-only check fails guest_pad.
  • At 7844bbb5e1 (main merged after #9178): guest_pad and guest_pad_vibration_mode pass three runs in a row on Windows 11 (WinLibs GCC 15.2) and on Linux (WSL2 6.18, GCC 16.2). guest_pad also checks that type 16 fails with INVALID_ARG for a user other than the system user, as measured.
  • tools/check_conventions.py passes.
  • tools/pr_overlap.py: #7881, #10119 touch nearby lines; whichever lands second keeps both.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #7881, #10119 (merge order only: they edit the same lines; this PR is refreshed after them)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4988054365 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10361). Originally posted by [orezraey](https://github.com/orezraey) on 2026-10-23T19:17:30Z. --- ### What `scePadOpen`'s argument checks measured on a retail PS5 (firmware 13.60) through `libScePad.sprx` from a payload process. The sources and console logs are in [this gist](https://gist.github.com/orezraey/67efd6430dd86a01d1e6c62eaaea3852) (`ppad`, `ppad2`). A payload process cannot open a port even for its logged-in user (it gets 0x809b0081, unknown user), so only the checks the console makes before that were reached. The console: - fails port types 1, 5, 6, 16, 255 and -1 with `INVALID_ARG` (0x80920001) whatever the user, so the type is checked first; - lets types 0, 2, 3 and 4 through the type check; - fails user -1 with 0x809b0001 on types 0, 2, 3 and 4 and on index 1 (`ppad`, where the payload had no initial user), and index 1 of the standard port with 0x809b0003 for a logged-in user (`ppad2`). AnyPS5 answered index 1 with `INVALID_ARG`, gave user -1 a handle, and failed types 3 and 4 with `INVALID_ARG`. It now answers user -1 and a non-zero index with the measured codes. Types 3 and 4 throw after the type and user checks, since the console accepts them and what they open is unknown; a title that probes them will stop here instead of getting a made-up error, which the new debt entry records. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11, MinGW (winlibs). - `guest_pad` checks user -1 on types 0, 2, 3 and 4 and on index 1, index 1 of a logged-in user and the invalid types. The pad tests pass three runs in a row. - At `199fd82e3d` (main merged after its 4-controller pad change, which limits the standard port to logged-in users): `scePadOpen` checks the port type alone first, then user -1 and the index, and leaves the standard port's user lookup to `PortForUser`; `libScePad.md` keeps main's deadband, legacy haptics and controller information entries with this PR's `scePadOpen` entries. `guest_pad` and `guest_pad_vibration_mode` pass three runs in a row on Windows 11 (WinLibs GCC 15.2) and on Linux (WSL2, GCC 16.2); a plain merge without the type-only check fails `guest_pad`. - At `7844bbb5e1` (main merged after #9178): `guest_pad` and `guest_pad_vibration_mode` pass three runs in a row on Windows 11 (WinLibs GCC 15.2) and on Linux (WSL2 6.18, GCC 16.2). `guest_pad` also checks that type 16 fails with `INVALID_ARG` for a user other than the system user, as measured. - `tools/check_conventions.py` passes. - `tools/pr_overlap.py`: #7881, #10119 touch nearby lines; whichever lands second keeps both. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #7881, #10119 (merge order only: they edit the same lines; this PR is refreshed after them) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-23 19:18:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T19:18:27Z.

Review: CHANGES_REQUESTED


The measured ordering for types 3 and 4 is not preserved for an invalid user. The report says these types pass the port-type check, then the payload process receives 0x809b0081 because it cannot open a port for its logged-in user; it separately reports that user -1 returns 0x809b0001 on a valid port type. In the implementation, type == 3 || type == 4 throws before userId is checked, so scePadOpen(-1, 3, 0, nullptr) and scePadOpen(-1, 4, 0, nullptr) throw instead of returning the measured invalid-user result. Please preserve the known argument validation before throwing for the unsupported open behavior, and add regression assertions for those combinations. The existing test currently covers invalid user only with type 0.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5633344938 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10361#pullrequestreview-5633344938). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T19:18:27Z. **Review:** CHANGES_REQUESTED --- The measured ordering for types 3 and 4 is not preserved for an invalid user. The report says these types pass the port-type check, then the payload process receives `0x809b0081` because it cannot open a port for its logged-in user; it separately reports that user `-1` returns `0x809b0001` on a valid port type. In the implementation, `type == 3 || type == 4` throws before `userId` is checked, so `scePadOpen(-1, 3, 0, nullptr)` and `scePadOpen(-1, 4, 0, nullptr)` throw instead of returning the measured invalid-user result. Please preserve the known argument validation before throwing for the unsupported open behavior, and add regression assertions for those combinations. The existing test currently covers invalid user only with type 0.
MarcZX10 commented 2026-10-23 19:55:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T19:55:24Z.

Review: APPROVED


Reviewed current head ddcc81887f. The follow-up preserves the measured ordering: unsupported port types 3/4 reach the invalid-user result for user -1 before the unimplemented path throws, while invalid types and the measured standard-port index case retain their results. GuestPad now covers the previously missing type 3/4 invalid-user cases and relevant invalid-type/index combinations; the debt entry records that type 3/4 index-1 behavior remains unknown. The author reports three passing Windows guest_pad runs. Hosted eligibility, conventions, labels and report checks pass; product jobs are skipped by policy. I did not run guest_pad locally: syntax compilation is blocked by the absent SDL2 submodule header SDL_scancode.h.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5633728621 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10361#pullrequestreview-5633728621). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T19:55:24Z. **Review:** APPROVED --- Reviewed current head ddcc81887f23e428a314470200db86d25fa3e8fd. The follow-up preserves the measured ordering: unsupported port types 3/4 reach the invalid-user result for user -1 before the unimplemented path throws, while invalid types and the measured standard-port index case retain their results. GuestPad now covers the previously missing type 3/4 invalid-user cases and relevant invalid-type/index combinations; the debt entry records that type 3/4 index-1 behavior remains unknown. The author reports three passing Windows guest_pad runs. Hosted eligibility, conventions, labels and report checks pass; product jobs are skipped by policy. I did not run guest_pad locally: syntax compilation is blocked by the absent SDL2 submodule header `SDL_scancode.h`.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!10361
No description provided.