pm4: reject truncated packets and bound packet-size inputs #1330
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1330
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1330/head"
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?
@HamsterCL on GitHub · 2026-10-09 20:44 UTC · original
HamsterCL:fix/pm4-packet-bounds→main· +25 −2 · 2 files · 2 commits · closed without mergingSplit out of #1313 (closed).
ProcessPm4now rejects a packet whose declared length is zero or exceeds the remaining command-buffer dwords before dispatch.WRITE_CONST_RAM,DUMP_CONST_RAM,GET_LOD_STATSandWRITE_DATAvalidate their guest-supplied sizes, andHwCtxSetAaSampleControlno longer reads one dword past a 20-dword packet.Built and ran all 53 ctest tests locally (Windows, clang-cl).
@HamsterCL on GitHub · 2026-10-09 20:45 UTC · original
@coderabbitai review
@coderabbitai[bot] on GitHub · 2026-10-09 20:49 UTC · original · edited 2026-10-10 02:31 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
783ff6e0-0528-4fff-abeb-0fed7a2df08e📥 Commits
Reviewing files that changed from the base of the PR and between 4df5a39693040d6948c4f2bf4ceb048839c749a2 and 4d4a3dbd377a4984fddb1c0368dd75c7c475e529.
📒 Files selected for processing (1)
src/graphics/guest_gpu/command_processor/pm4Handlers.cpp🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.
📝 Walkthrough
📝 Walkthrough
Walkthrough
ProcessPm4now checks non-predicated packet lengths before dispatch. Handler checks validate payload lengths, the LOD statistics buffer size, and constant-RAM ranges.Priority: ⬇️ Low
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
4d4a3No actionable merge-blocking issue remains in the inspected PM4 validation paths.
Pre-merge checks |
4 |
1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
HwCtxSetAaSampleControlfix, and the reported test coverage.Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@ -751,0 +754,4 @@// packet that claims to be longer than what's actually left in the command// buffer before dispatch, so a handler can never read past the command span.const auto declared_packet_dw = KYTY_PM4_LEN(packet_header);EXIT_NOT_IMPLEMENTED(declared_packet_dw == 0 || declared_packet_dw > remaining_dw);@coderabbitai[bot] on GitHub · 2026-10-09 20:49 UTC · original · edited 2026-10-09 20:53 UTC
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3691
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 23061
Reject undersized
SET_CONTEXT_REGpackets before reading the value.KYTY_PM4_LENincludes the header. A packet with one payload dword has length 2, passes the framing check, and reachesCpOpSetContextReg. That handler readsbuffer[1], which is outside the packet and can be outside the command span when the packet ends the buffer.Add the minimum packet-length guard before the first handler read:
🐛 Suggested fix
✅ Addressed in commit 4d4a3db
@coderabbitai[bot] on GitHub · 2026-10-09 20:49 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
4f87f5e2-f1ec-4129-91a3-9926d42fc447📥 Commits
Reviewing files that changed from the base of the PR and between
59183dbfa8and 4df5a39693040d6948c4f2bf4ceb048839c749a2.📒 Files selected for processing (2)
src/graphics/guest_gpu/command_processor/pm4Handlers.cppsrc/graphics/guest_gpu/graphicsRun.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
@coderabbitai[bot] on GitHub · 2026-10-09 20:53 UTC · original · edited 2026-10-09 20:57 UTC
✅ Action performed
Review finished.
@HamsterCL on GitHub · 2026-10-09 20:58 UTC · original
@coderabbitai review
@coderabbitai[bot] on GitHub · 2026-10-09 20:58 UTC · original
⚠️ Action not completed
Already reviewed the last commit. Use
@coderabbitai full reviewto rerun a review of the entire changeset.@HamsterCL on GitHub · 2026-10-10 02:30 UTC · original
Rebased onto current main. @coderabbitai review
@coderabbitai[bot] on GitHub · 2026-10-10 02:31 UTC · original
@HamsterCLI’ll trigger a review of the rebased changes.⚠️ Action not completed
Already reviewed the last commit. Use
@coderabbitai full reviewto rerun a review of the entire changeset.Pull request closed