loader/crash: bound VEH instruction reads, guard clzero writability, and fix MSVC thrown() null derefs #478
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/478"
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-25T01:22:52Z.
Problem
In
crates/victory-loader/src/crash.rs, three defects could cause nested Access Violations inside the vectored exception handler or crash reporter:clzerofallthrough AV: Whenconsole_insn::emulatereturns0because aclzerotarget is not writable (console_insn.rs:158-159),handlerfalls through toemulate_amd_only(info)(crash.rs:370), which unconditionally executed((context.Rax & !63) as *mut u8).write_bytes(0, 64)with no writability check, crashing inside the VEH.emulate_amd_onlyandsse4a:emulate_amd_onlyread[u8; 3]fromcontext.Ripbefore computingroom = 0x1000 - (Rip & 0xfff), and passed the rawcodepointer instead of the page-bounded&bytes[..n]slice tosse4a(), which indexed up tocode.add(6)unchecked. Any 1–6 byte illegal instruction at the end of a page adjacent to aPAGE_NOACCESS/unmapped page faulted inside the VEH.thrown(): On a C++ rethrow (throw;, wherep[1] == 0, p[2] == 0),thrown()readp[2] + 12(0xC), calledname(0)without checkingcount = rva(types) > 0, and dereferencedp[1]on thestd::exceptionbranch without checkingp[1] != 0.Fix
room = 0x1000 - (Rip & 0xfff)) at the top ofemulate_amd_onlybefore matchingclzero/monitorx/mwaitx,clwb_loop,clwb_len, orsse4a.sse4ato take a bounded&[u8]slice usingcode.get(...).clzeroline is committed and writable (VirtualQuery) before writing inemulate_amd_only, returningfalseotherwise.p[2] == 0 || p[3] == 0, zero RVA / empty catchable type array, andp[1] == 0inthrown().clzero(read-only page viaemulate_amd_onlyandhandler), page-boundary illegal instructions (ud2at+0xFFE, truncated SSE4a prefix at+0xFFD) adjacent toPAGE_NOACCESS, andthrown()with MSVC rethrow (p[2] == 0) / nullp[1].Verification
cargo test -p victory-loader --locked: 25 unit + 3 integration passed, 0 failedcargo xtask policy: 169 files okcargo clippy -p victory-loader --all-targets --locked -- -D warnings: cleancargo clippy -p victory-loader --all-targets --all-features --locked -- -D warnings: clean(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.