loader/crash: prevent RSP overflow and unaligned read UB in unwind_into #791
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/791"
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?
Imported from fxceless/victory-fork. Originally posted by AscilCH on 2026-11-25T07:35:46Z.
Summary
Fix stack-unwinder safety and bounds-check issues in
crates/victory-loader/src/crash.rs:unwind_into()rsp + 8 > highinteger overflow:rsp + 8panics in debug builds or wraps pasthighin release builds when a crashing thread has a corruptedRsp > usize::MAX - 8.rsp.checked_add(8).is_none_or(|end| end > high)and stop unwinding if an iteration makes no(Rip, Rsp)progress.Unaligned return-address read UB in
unwind_into():entry.is_null()),(rsp as *const u64).read()is UB (and panics in debug builds) if the crashing thread has a misalignedRsp.(rsp as *const u64).read_unaligned()andwrapping_add(8).Defensive
module_of()checks:NoneifGetModuleFileNameWfails (len == 0) or ifaddress < module as usize.Verification
cargo test -p victory-loader --locked:25 passed; 0 failedunit tests (including newcrash::tests::unwind_into_handles_overflowing_and_unaligned_rsp), plus2 passed(load_probe) and1 passed(title_dlls).cargo clippy -p victory-loader --all-targets --all-features --locked -- -D warnings: 0 warnings.cargo xtask policy:171 files ok.(AI-assisted; synthetic unit tests only, 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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.