fix(libSceUsbStorageDialog): validate guest parameters readability in sceUsbStorageDialogOpen #16051

Merged
pushkarreddyy merged 5 commits from upstream-pr/16051 into main 2026-11-08 17:36:56 +00:00
pushkarreddyy commented 2026-11-05 13:10:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-11-05T13:10:41Z.


What

Safely validate guest parameter readability via GuestCopyIn_nid_no_patch in sceUsbStorageDialogOpen. If the supplied param pointer points to unmapped or unwritable memory, return COMMON_DIALOG_ERROR_ARG_NULL (0x80B8000D) while preserving guest errno. Validation checks are performed directly on the copied local parameter struct (local.base), avoiding repeated reads from guest memory.

Documented in docs/dev/debt/libSceUsbStorageDialog.md under ### Host-safety fallback.

Tested

  • Windows 11, verified with guest_usb_storage_dialog_tests:
    • sceUsbStorageDialogOpen(nullptr) returns COMMON_DIALOG_ERROR_ARG_NULL.
    • sceUsbStorageDialogOpen(0x10) returns COMMON_DIALOG_ERROR_ARG_NULL across uninitialized, initialized, and running states.
  • Verified python tools/check_conventions.py --base origin/main passes with 0 errors.

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: none
  • Fixes: Fixes #16045
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5172107094 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16051). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-11-05T13:10:41Z. --- ### What Safely validate guest parameter readability via `GuestCopyIn_nid_no_patch` in `sceUsbStorageDialogOpen`. If the supplied `param` pointer points to unmapped or unwritable memory, return `COMMON_DIALOG_ERROR_ARG_NULL` (`0x80B8000D`) while preserving guest `errno`. Validation checks are performed directly on the copied local parameter struct (`local.base`), avoiding repeated reads from guest memory. Documented in `docs/dev/debt/libSceUsbStorageDialog.md` under `### Host-safety fallback`. ### Tested - Windows 11, verified with `guest_usb_storage_dialog_tests`: - `sceUsbStorageDialogOpen(nullptr)` returns `COMMON_DIALOG_ERROR_ARG_NULL`. - `sceUsbStorageDialogOpen(0x10)` returns `COMMON_DIALOG_ERROR_ARG_NULL` across uninitialized, initialized, and running states. - Verified `python tools/check_conventions.py --base origin/main` passes with 0 errors. ### 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: none - [x] Fixes: Fixes #16045 - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
mashingaan commented 2026-11-07 11:21:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mashingaan on 2026-11-07T11:21:51Z.

Review: APPROVED


The copy-in plus the guestAddress-aware ValidateCommonDialogBaseParam keep the magic check on the caller's address, and the errno save/restore around GuestCopyIn is correct. The null and 0x10 cases are covered. No findings.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5811900039 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16051#pullrequestreview-5811900039). Originally posted by [mashingaan](https://github.com/mashingaan) on 2026-11-07T11:21:51Z. **Review:** APPROVED --- The copy-in plus the guestAddress-aware ValidateCommonDialogBaseParam keep the magic check on the caller's address, and the errno save/restore around GuestCopyIn is correct. The null and 0x10 cases are covered. No findings.
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!16051
No description provided.