fix(agc): reject NOP data packets whose count overflows the header #14993
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14993"
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 MarcZX10 on 2026-11-02T08:52:55Z.
What
sceAgcDriverNopDataWritePacketstorestotalBytes / 4 - 2in the 14-bit PM4 type-3 count field (bits 16-29). For payloads above 65532 bytes the count wraps into the opcode bits.libSceAgcDriver.sprx, read from disassembly, not measured on a console) has no size check here: the header is computed in 32 bits, the whole packet is still written and the result is stilltotal / 4. This PR matches that, so there is no code change inUnimplemented.cpp.0xffff1000, 16385 dwords) and 65536 bytes (wrapped header0xc0001000, 16386 dwords, destination bounds checked).Commits:
fix(agc)(rejection, later reverted),test(agc),docs(agc), thenrevert(agc)commits that remove the rejection again and restoreUnimplemented.cppto the PR base.Tested
91ca789c74, Linux (Debian, kernel 6.1), archive build via the shared validation tool:agc_driver_nop_data_packetpassed (1/1, ctest #1596).python3 tools/check_conventions.py --baseandgit diff --checkclean.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)Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T10:33:38Z.
Review: CHANGES_REQUESTED
Thanks for the boundary test. The new check, though, makes this export depart from what firmware 13.42 does, so I'm requesting changes.
Firmware 13.42's
libSceAgcDriver.sprx(sha25678d5ad5fb70cc874b88841035218963a063199c4513607fa8f87242b66b6277b) exportssceAgcDriverNopDataWritePacket(mQfUoU5-d1g) at 0x7120. I read it to the return, from disassembly only, not measured on a console. It has no size check at all:The header is computed in 32 bits (
shl r14d, 0xe), so forbytesabove 65532 the count wraps into the opcode bits exactly as onmain. The whole packet is still zeroed and written, and the result is stilltotal / 4(2 for null data or zero bytes).main'sUnimplemented.cppalready reproduces this, wrap included.Returning 0 and writing nothing is a result the module never gives. The debt entry would then record an invented answer as unmeasured, when the module settles it. I'd suggest either:
0xc0001000 | ((65544 << 14) + 0x3ffe0000)and a result of 16386, which pins the firmware behaviour; orI didn't build this branch. The objection is about the contract, not the test.
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-06T15:57:58Z.
Review: APPROVED
@MarcZX10 re-checked at
91ca789c74, thanks for taking the first option. My change request was on686225f1ac.Unimplemented.cppis identical tomainat this head (git diff upstream/main...is empty for it), so the export keeps the 32-bit header and thetotal / 4result my earlier note described.NopDataWritePacket.cpp:56expects header0xffff1000and 16385 for 65532 bytes, andNopDataWritePacket.cpp:65expects0xc0001000and 16386 for 65536 bytes, plus the payload ends and the bytes on either side of the packet.shl 0xe,add 0x3ffe0000,or 0xc0001000, resulttotal >> 2): 65532 gives0xffff1000/16385 and 65536 gives0xc0001000/16386, matching the test.docs/dev/debt/libSceAgcDriver.md:46at this head) states the wrap as read from 13.42's disassembly, not measured on a console.What I ran. This head merged onto
main7383be1a19(merge6e5372fc74, clean), Windows 11 Pro, WinLibs GCC, Release:agc_driver_nop_data_packet: 1 of 1 passes, none unbuilt.main'ssceAgcDriverNopDataWritePacketon the merge, each rebuilt and run. Both failagc_driver_nop_data_packet:return 0for packets above 65540 bytes (the rejection this PR first added).tools/pr_overlap.py --branchat this head: no line conflicts. 47 pull requests share onlydocs/dev/debt/libSceAgcDriver.mdand couldn't be compared; in GitHub's patches for 45 of them no changed line namesNopDataWritePacket, #13486's file list doesn't include that file, and #14212's patch is too large for GitHub to show.AI-assisted: yes (Claude Code)