Repository navigation
fix(libSceUsbStorageDialog): return INVALID_ARGUMENT from sceUsbStorageDialogGetResult for an unwritable result - #14965
Conversation
…geDialogGetResult for an unwritable result
BunnyFl
left a comment
There was a problem hiding this comment.
A firmware note for the debt entry, not a blocker. The checked copies do keep the host from faulting.
Firmware 13.42's libSceUsbStorageDialog.sprx (sha256 ed1e0fbffb7169e0b52b10b5b649204249d701b136b42f684ffe699edd463beb) at 0x500 (ul-kdmwPExY), read to the return, from disassembly only, not measured on a console:
507: test rdi, rdi ; je 590 ; 590: 0x80b8000d (null only)
... (initialization and status checks: 0x80b80003, 0x80b80005)
540: cmp eax, 0x4500000 ; jb 55c ; SDK version gate
547: cmp qword [rbx], 0x50 ; direct read of result->size
553: cmp dword [rbx+8], 0x80b80007 ; direct read of result->result
577: mov [rbx+8], eax ; direct store
58b: mov [rbx+0xc], eax ; direct store
The module tests only for null, then loads and stores straight through the pointer. There's no syscall or copyin/copyout first, so for a non-null pointer it can't access, the console faults rather than returning a code, and main already matches that.
Could the debt entry say so instead of "unmeasured"? For example: "Firmware 13.42 checks only for null and accesses the structure directly, so the console faults on an inaccessible non-null pointer; AnyPS5 returns COMMON_DIALOG_ERROR_INVALID_ARGUMENT instead." That matches how the libkernel entries word their "returns EFAULT here, where the console faults" fallbacks, and the new tests then pin a documented host-side fallback.
… for inaccessible result pointers
|
BunnyFl
left a comment
There was a problem hiding this comment.
Thanks, @fogydes. The debt entry now says what firmware 13.42 does (null check only, direct access, so the console faults) and where AnyPS5 deliberately differs. It keeps the 'read from disassembly, not measured on a console' evidence. The code is unchanged since my last read and matches the module; the new tests pin the documented host-side fallback.
|
A Windows run with GCC 16: Windows 11 Pro 10.0.22631, i9-9900K, MSYS2 UCRT64 GCC 16.1.0, Release, this PR (
Looks good on Windows 👍 AI-assisted: yes (Claude Code) |
What
Validate caller result pointers in
sceUsbStorageDialogGetResultviaGuestCopyIn_nid_no_patchandGuestCopyOut_nid_no_patchpreservingerrno, returningCOMMON_DIALOG_ERROR_INVALID_ARGUMENT(0x80B8000Au) when the buffer is unreadable or unwritable rather than causing an unhandled host access violation (0xc0000005).Tested
Windows 11 x86_64,
ctest --test-dir build -R guest_usb_storage_dialog -V(100% pass). Verified unwritable/unreadable pointerreinterpret_cast<UsbStorageDialogResult*>(0x10)returnsCOMMON_DIALOG_ERROR_INVALID_ARGUMENT.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)