GPU: check subobject size against remaining stream bytes in create_st… #1537

Closed
Texbirds wants to merge 1 commit from upstream-pr/1538 into main
Texbirds commented 2026-11-24 18:58:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Texbirds on 2026-11-24T18:58:19Z.


Problem

create_stream in crates/victory-gpu/src/pipeline.rs checks only while at + 8 <= desc.size before reading a subobject header, then immediately dereferences Bytecode at at + 8 and calls graphics.read(kind, desc.stream.add(at)) (which reads up to 336 bytes for blend state kind == 8) without checking that size <= desc.size - at. A truncated trailing subobject reads past the end of the title's stream buffer.

Fix

  • Check size > desc.size - at immediately after subobject(kind) and stop parsing with a warning if truncated.
  • Add Windows guard-page regression test truncated_stream_subobject_does_not_read_past_end placing 8-byte truncated kind = 1 (24-byte shader) and kind = 8 (336-byte blend) subobjects right before a PAGE_NOACCESS guard page.

Verification

  • Pending windows-latest CI (cargo clippy default + --all-features and cargo test --workspace --locked).
<!-- greyfinch-sync:Marvisak/VIctory:issue:6589173386 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1538). Originally posted by [Texbirds](https://github.com/Texbirds) on 2026-11-24T18:58:19Z. --- ### Problem `create_stream` in `crates/victory-gpu/src/pipeline.rs` checks only `while at + 8 <= desc.size` before reading a subobject header, then immediately dereferences `Bytecode` at `at + 8` and calls `graphics.read(kind, desc.stream.add(at))` (which reads up to 336 bytes for blend state `kind == 8`) without checking that `size <= desc.size - at`. A truncated trailing subobject reads past the end of the title's stream buffer. ### Fix - Check `size > desc.size - at` immediately after `subobject(kind)` and stop parsing with a warning if truncated. - Add Windows guard-page regression test `truncated_stream_subobject_does_not_read_past_end` placing 8-byte truncated `kind = 1` (24-byte shader) and `kind = 8` (336-byte blend) subobjects right before a `PAGE_NOACCESS` guard page. ### Verification - Pending `windows-latest` CI (`cargo clippy` default + `--all-features` and `cargo test --workspace --locked`).
upstream-sync closed this pull request 2026-11-25 01:06:48 +00:00
Marvisak commented 2026-11-25 01:08:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:42:11Z.


Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

Already in main: read_stream checks at + size > stream.len() before reading a subobject (pipeline.rs).

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148787412 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1538#issuecomment-7148787412). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:42:11Z. --- Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. Already in main: read_stream checks `at + size > stream.len()` before reading a subobject (pipeline.rs). If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

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
Marvisak/VIctory!1537
No description provided.