Bounds-check pipeline stream subobjects before reading #350

Manually merged
github merged 1 commit from github-bot/gh-350 into gh-pr/350/base 2026-11-27 19:39:07 +00:00 AGit
Owner

@⁠ahmetbagci8 on GitHub · 2026-11-27 19:09 UTC · original
ahmetbagci8:fix/gpu-pipeline-stream-bounds → main · +51 −3 · 1 files · 1 commits · merged 2026-11-27 19:37 UTC

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)
**@⁠ahmetbagci8** on GitHub · 2026-11-27 19:09 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/350) `ahmetbagci8:fix/gpu-pipeline-stream-bounds` → `main` · +51 −3 · 1 files · 1 commits · merged 2026-11-27 19:37 UTC ### 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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 19:11:41 +00:00
github-bot changed target branch from main to gh-pr/350/base 2026-11-27 19:39:05 +00:00
github manually merged commit bca4502e54 into gh-pr/350/base 2026-11-27 19:39:07 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 19:37 UTC · original

@⁠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.

**@⁠TaynanGT** on GitHub · 2026-11-27 19:37 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/350#issuecomment-7226717344) @⁠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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.