Bounds-check pipeline stream subobjects before reading #350

Merged
ahmetbagci8 merged 1 commit from upstream-pr/350 into main 2026-11-27 19:37:02 +00:00
ahmetbagci8 commented 2026-11-27 19:09:29 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by ahmetbagci8 on 2026-11-27T19:09:29Z.


Summary

In crates/victory-gpu/src/pipeline.rs, create_stream checked only at + 8 <= desc.size before reading each subobject (whose size ranges from 8 to 336 bytes) and created an aligned reference &* to Bytecode inside the byte-aligned stream buffer. A truncated subobject would read past desc.stream + desc.size (violating GraphicsState::read's safety contract and reading out-of-bounds Bytecode).

Changes

  • Stop scanning with a warning if size > desc.size - at.
  • Read shader Bytecode with read_unaligned().
  • Add unit test truncated_pipeline_stream_is_not_read_past_size.

Tested

  • cargo test -p victory-gpu --lib pipeline: 35 passed; 0 failed; 1 ignored
  • cargo clippy -p victory-gpu --tests: clean (0 warnings)
<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:5531838402 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/350). Originally posted by [ahmetbagci8](https://github.com/ahmetbagci8) on 2026-11-27T19:09:29Z. --- ### Summary In `crates/victory-gpu/src/pipeline.rs`, `create_stream` checked only `at + 8 <= desc.size` before reading each subobject (whose size ranges from 8 to 336 bytes) and created an aligned reference `&*` to `Bytecode` inside the byte-aligned stream buffer. A truncated subobject would read past `desc.stream + desc.size` (violating `GraphicsState::read`'s safety contract and reading out-of-bounds `Bytecode`). ### Changes - Stop scanning with a warning if `size > desc.size - at`. - Read shader `Bytecode` with `read_unaligned()`. - Add unit test `truncated_pipeline_stream_is_not_read_past_size`. ### Tested - `cargo test -p victory-gpu --lib pipeline`: `35 passed; 0 failed; 1 ignored` - `cargo clippy -p victory-gpu --tests`: clean (0 warnings)
TaynanGT commented 2026-11-27 19:37:54 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-27T19:37:54Z.


@ahmetbagci8 This is on main as bc78af6. The stream reader now checks the whole subobject before reading it and accepts bytecode from unaligned streams. Both test suites and Clippy passed.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7226717344 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/350#issuecomment-7226717344). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-27T19:37:54Z. --- @ahmetbagci8 This is on `main` as `bc78af6`. The stream reader now checks the whole subobject before reading it and accepts bytecode from unaligned streams. Both test suites and Clippy passed.
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
TaynanGT/Vice-Tay!350
No description provided.