GPU: guard BND epilogues and saved-register bounds in profile unwind check #870
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!870
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-870"
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?
@adritoyalser on GitHub · 2026-11-25 11:12 UTC · original
adritoyalser:fix/profile-unwind-bounds→main· +255 −20 · 2 files · 1 commits · openSummary
Hardens the pre-unwind safety checks in
crates/victory-gpu/src/profile.rs(frame_fitsandepilogue_fits) against four edge cases that can causeRtlVirtualUnwindto read outside the copied stack buffer (STATUS_ACCESS_VIOLATION) or overflow/read past unwind code arrays:bnd(0xf2) prefix inepilogue_fits: WindowsRtlVirtualUnwindskips a single0xf2prefix before matching epilogue terminators (c3,c2,eb,e9,f3 c3,ff 25,rex ff /4). Previouslyepilogue_fitsdid not skip0xf2, so sequences likepop rsp; bnd ret(5c f2 c3) oradd rsp, <large>; bnd retwere treated as non-epilogues (leaves == false) and passed toRtlVirtualUnwind, faulting insidentdll.frame_fits:UWOP_SAVE_NONVOL(4),UWOP_SAVE_NONVOL_FAR(5),UWOP_SAVE_XMM128(8), andUWOP_SAVE_XMM128_FAR(9) now updatesave_end, andreach = frame_size.saturating_add(64).max(save_end)ensures reads at those offsets stay withinlimit.UWOP_PUSH_MACHFRAME: Multi-slot codes (1,4,5,7,8,9) verifyi + 2 <= count/i + 3 <= countbefore reading extra slots,UWOP_ALLOC_LARGErejectsop_info > 1, andUWOP_PUSH_MACHFRAME(10) is rejected when followed by more unwind codes or a chained parent (since it replacesRspfrom the stack).image + finish - context.Rip,reach += ...,rsp + reach <= limit,base + reach <= limit, andrsp + 8 * (pops + 1) <= endwith checked/saturating arithmetic.Verification
frame_fits_accounts_for_saved_register_offsets_and_truncated_codesandepilogue_fits_recognizes_bnd_prefixed_epiloguesincrates/victory-gpu/src/profile/tests.rs(including liveRtlVirtualUnwindverification for bothUWOP_SAVE_NONVOLand0xf2 c3).cargo test -q -p victory-gpu --lib --features diagnostics --locked profile -- --test-threads=1: 11 passed, 0 failed, 1 ignored (profile_cost).cargo clippy -q -p victory-gpu --lib --tests --features diagnostics --locked: 0 warnings inprofile.rs/profile/tests.rs.rustfmt --edition 2024 --check crates/victory-gpu/src/profile.rs crates/victory-gpu/src/profile/tests.rs: clean.@MamaLeVrai on GitHub · 2026-11-25 12:23 UTC · original
Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head
d36d089intomainf85101bin a throwaway tree (no conflict).cargo clippy --workspace --all-targets --locked -- -D warningsfails with exactly the errorsmainitself has on this machine (placed_filler_twins,depth_written, a sort; PR #841 fixes them), also with--all-features; this PR adds none.cargo test --workspace --locked: run 1: 555 passed, 0 failed, 11 ignored; run 2: stopped atindirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields(the one that fails onmainitself most runs here (PR #849 and #847 fix its assertion)) (mainalone: 555 passed, 0 failed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data.AI-assisted (Claude Code); no game data.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.