GPU: reject overflowing FirstElement and NumElements arithmetic in buffer view creation #2541
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2541
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2541/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?
@reeledMarek on GitHub · 2026-11-25 15:33 UTC · original
reeledMarek:fix/gpu-buffer-view-overflow→main· +64 −16 · 1 files · 1 commits · closed without mergingProblem
In
crates/victory-gpu/src/descriptor/host.rs,buffer_range,unordered_range,buffer_srv, andbuffer_uavcomputedaddress + buffer.FirstElement * elementandu64::from(buffer.NumElements) * elementwith uncheckedu64arithmetic.A large
FirstElement(such as1 << 60withStructureByteStride = 16, oru64::MAX) panics in debug builds and silently wraps in release builds before reachingwithin(), producing a bogusstartaddress. Additionally,buffer_rangeandunordered_rangedid not verifyViewDimension == BUFFERbefore reading theBufferunion member.Fix
checked_buffer_range(base, first, count, element)usingchecked_mulandchecked_add, rejecting anyu64overflow.desc.ViewDimension == D3D12_SRV_DIMENSION_BUFFER/D3D12_UAV_DIMENSION_BUFFERbefore accessingdesc.Anonymous.Buffer.Testing
overflowing_buffer_ranges_are_refusedincrates/victory-gpu/src/descriptor/host.rs.cargo test -p xtask --lockedpasses asset policy.@Marvisak on GitHub · 2026-11-25 18:34 UTC · original
Automated triage for the maintainers.
Replaces the unchecked
base + FirstElement * element/NumElements * elementarithmetic inbuffer_range,unordered_range,buffer_srvandbuffer_uav(crates/victory-gpu/src/descriptor/host.rs) withchecked_buffer_range, and addsViewDimension == BUFFERchecks before the union read.As it stands, the value is unclear:
buffer_rangereaches it only for a buffer resource (buffer_bytes(..)?orresource[0] == 1), and D3D12 only allows buffer-dimension views on buffers. So the newViewDimensionchecks guard a case that cannot occur.FirstElement/NumElementscome from the title's own view descriptions. Release builds wrap, andshadow::for_view/within(which already saturates) then refuse the view. So the overflow only matters for a debug-build panic on a garbage descriptor.What would change the verdict: a real case where such a view reaches these functions, such as a log line from a run or a descriptor path where uninitialised words are read. Without one, this is a guard for a case that does not occur, and a maintainer may prefer to close it.
CI: passing.
Generated by Claude Code
@reeledMarek on GitHub · 2026-11-25 20:05 UTC · original
Closing per triage — release builds wrap and
within()already rejects invalid buffer views without a concrete triggering title descriptor. Thanks for the review!Pull request closed