GPU: fix integer-overflow bounds checks in resolve_queries, execute_i… #537

Open
github-bot wants to merge 1 commit from github-bot/gh-537 into main AGit
Owner

@⁠pug205gti6 on GitHub · 2026-11-25 02:01 UTC · original
pug205gti6:pr/480-gpu-list-draw-fix → main · +186 −13 · 2 files · 1 commits · open

…ndirect, and State::rectangles

  1. list::resolve_queries: replace unchecked offset + u64::from(count) * bytes > size with checked multiplication and addition so wrapping offsets cannot panic in debug builds or bypass the buffer bounds check in release builds and schedule an out-of-bounds defer_write.
  2. list::execute_indirect: validate arguments ([offset, offset + stride * max.max(1))) and count ([count_offset, count_offset + 4)) against each buffer's recorded byte size using checked arithmetic (checked_buffer_offset), preventing out-of-bounds or wrapping offsets from aliasing adjacent Shadow buffers.
  3. draw::State::rectangles: widen u64::from(first) + u64::from(count) before multiplying by stride (avoiding u32 wrap on first + count), use checked addition for v.address + first * stride, and check u32::try_from(rects * 6 * stride) so D3D12_VERTEX_BUFFER_VIEW::SizeInBytes cannot silently truncate.

Add synthetic unit tests in list::tests and draw::tests.

**@⁠pug205gti6** on GitHub · 2026-11-25 02:01 UTC · [original](https://github.com/fxceless/victory-fork/pull/537) `pug205gti6:pr/480-gpu-list-draw-fix` → `main` · +186 −13 · 2 files · 1 commits · open …ndirect, and State::rectangles 1. `list::resolve_queries`: replace unchecked `offset + u64::from(count) * bytes > size` with checked multiplication and addition so wrapping offsets cannot panic in debug builds or bypass the buffer bounds check in release builds and schedule an out-of-bounds `defer_write`. 2. `list::execute_indirect`: validate `arguments` (`[offset, offset + stride * max.max(1))`) and `count` (`[count_offset, count_offset + 4)`) against each buffer's recorded byte size using checked arithmetic (`checked_buffer_offset`), preventing out-of-bounds or wrapping offsets from aliasing adjacent `Shadow` buffers. 3. `draw::State::rectangles`: widen `u64::from(first) + u64::from(count)` before multiplying by `stride` (avoiding `u32` wrap on `first + count`), use checked addition for `v.address + first * stride`, and check `u32::try_from(rects * 6 * stride)` so `D3D12_VERTEX_BUFFER_VIEW::SizeInBytes` cannot silently truncate. Add synthetic unit tests in `list::tests` and `draw::tests`.
1. `list::resolve_queries`: replace unchecked `offset + u64::from(count) * bytes > size` with checked multiplication and addition so wrapping offsets cannot panic in debug builds or bypass the buffer bounds check in release builds and schedule an out-of-bounds `defer_write`.
2. `list::execute_indirect`: validate `arguments` (`[offset, offset + stride * max.max(1))`) and `count` (`[count_offset, count_offset + 4)`) against each buffer's recorded byte size using checked arithmetic (`checked_buffer_offset`), preventing out-of-bounds or wrapping offsets from aliasing adjacent `Shadow` buffers.
3. `draw::State::rectangles`: widen `u64::from(first) + u64::from(count)` before multiplying by `stride` (avoiding `u32` wrap on `first + count`), use checked addition for `v.address + first * stride`, and check `u32::try_from(rects * 6 * stride)` so `D3D12_VERTEX_BUFFER_VIEW::SizeInBytes` cannot silently truncate.

Add synthetic unit tests in `list::tests` and `draw::tests`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:45:43 +00:00
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/draw.rs
  • crates/victory-gpu/src/list.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/537/head:github-bot/gh-537'
git switch 'github-bot/gh-537'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-537'
git switch 'github-bot/gh-537'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-537'
git switch 'github-bot/gh-537'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-537'
git switch 'main'
git merge --squash 'github-bot/gh-537'
git switch 'main'
git merge --ff-only 'github-bot/gh-537'
git switch 'main'
git merge 'github-bot/gh-537'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.