feat(libSceVideodec): check sceVideodecMapMemory's arguments as firmware 13.42 does #19451
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19451"
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 BunnyFl on 2026-11-13T10:51:14Z.
What
sceVideodecMapMemorynow returns the argument errors firmware 13.42 returns before it calls into the decoder, and still throws after those checks. It gets the parameters the checks read:(SceVideodec::Ctrl* ctrl, const void* memory).ctrlormemorynull0x80c1000fctrl->thisSize(64-bit) is not 240x80c10002memory+0is not0x20,0x28or0x480x80c10002ctrl->handle(ctrl+8) is null0x80c100030x28or0x48and the 32-bit field atmemory+0x20is not 00x80c10000The one call on each failing path is the module's
printf(PLT stub0x1a20, slot0x8048, imported ashcuQgD53UxM), which writes a[%s@%04X%04X:%08llX]debug line. That print is not reproduced: a title cannot observe it beyond debug output.Notes:
lea -0x20(%rcx),%rax; cmp $0x28,%rax; ja, thenbt %raxagainst0x10000000101(bits 0, 8 and 40), so exactly0x20,0x28and0x48pass. With0x20the module skips the+0x20field and goes straight to the decoder call.mov 0x8(%rdi),%rax; test %rax,%rax), not a lookup of a created decoder; the passing path calls the decoder's import (0x1b10, slot0x80c0) with the pointer stored athandle+0x50(mov 0x50(%rax),%rdi), and that path keeps throwing.GuestCopyIn_nid_no_patchright before its check, in the module's order (onlyctrl+8for the handle, andmemory+8to+0x23, which the module reads before it tests+0x20). A field that cannot be read falls through to the throw, where the console would fault. The library's other exports answer an unreadable control or argument block with0x80c1000f(an unreadable frame buffer with0x80c1000c); that host-safety fallback is theirs and is not extended to this export.testMapMemoryin the existingcore/libs/tests/GuestVideodec.cpp(guest_videodec), called after the existing ones. The debt entry forsceVideodecMapMemorynow says what still throws and that the print is not reproduced. No open pull request touches any of these files.Source
Firmware 13.42
system/common/lib/libSceVideodec.sprx(sha2562f595fa415a77ff34e283d1cbd5bcd02331d856381579a98d20a7f5dac49468d), read from disassembly, not run on a console. The entry (kg+lH0V61hM,0xbd0) comes from the module's dynamic symbol table; the PLT slots were named through the firmware test harness's relocation table (review-tools/emu_sprx.py).0x1a30(slot0x8050,Ou3iL1abvng) is the stack-protector failure path.Listing: sceVideodecMapMemory from its entry to its returns
Tested
Windows 11 Pro 10.0.26300, WinLibs GCC 15.2, Release, head
e454c627d5(based onmain00b3b52a3e).guest_videodec: passes, none Not Run, withlibSceVideodecand the test executable rebuilt. The newtestMapMemorydrives every error in the table above: both nulls; a control block size of 32; nine memory sizes around the accepted three (0,0x18,0x1f,0x21,0x30,0x40,0x47,0x49,0x50) with a null handle, so the size check is shown to come before the handle check; a null handle for each accepted size with a non-zero+0x20field, so the handle check is shown to come before that field; and three non-zero+0x20values for sizes0x28and0x48. It calls no passing path.ad644d076a, a throwaway commit one454c627d5that putsmain's throwing body back intosceVideodecMapMemoryand keeps the test and the signature,guest_videodecfails withsceVideodecMapMemory not implemented.tools/check_conventions.py --base upstream/mainon the committed head: all checks pass.review-tools'sig_users.py HEAD --build: builds every target that names the changed declaration.tools/pr_overlap.py --branch feat/videodec-mapmemory-checks --jobs 8on the head: no overlap with open pull requests.main648ba19b3einto the branch ase3e8172ed6, with no conflicts. On that head:tools/check_conventions.py --base upstream/mainpasses,guest_videodec: 1 of 1 pass, none Not Run,review-tools'sig_users.py HEAD --buildbuilds every user of the changed declarations, andtools/pr_overlap.pyfinds no overlap with open pull requests.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-15T21:00:10Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
e454c627d5:tools/check_conventions.pypassed;git diff --checkclean.guest_videodec_testsbuilt cleanly.guest_videodec):core/libs/prx/libSceVideodec/Export.cpp,core/libs/prx/libSceVideodec/include/Api.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me