Loader: the illegal-instruction handler reads no byte past the faulting page (ud2 at a page end faulted inside it) #259
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/259"
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 avatarmanz/VIctory-7900XTX. Originally posted by sharan104 on 2026-11-26T13:33:19Z.
crash.rs'semulate_amd_onlyhandles everyEXCEPTION_ILLEGAL_INSTRUCTION.console_insn::emulatepasses everyud2on to it, so this path is live. It read 3 bytes at the faultingRipbefore checking where the page ends, andsse4athen read up to 6 more through a raw pointer. So two cases made the handler fault inside VIctory itself when the next page is unmapped:ud2in the last 2 bytes of a pageextrq/insertqcut off by the page endThe title's handlers then saw an access violation coming from our handler, instead of the illegal instruction they expected. The bounded copy was already there for the
clwbpaths; it just came too late.Fix: the bytes left in the faulting page (up to 32) are copied once, up front, and every check reads only that copy.
sse4anow takes a slice, returnsNonewhere the bytes end before the instruction does, and is no longerunsafe. Behaviour for whole instructions is unchanged.Test:
nothing_past_the_page_is_read_for_an_instruction_at_its_endplaces aud2, a truncatedextrqand a wholeextrqin the last bytes of a page whose next page isPAGE_NOACCESS. Before the fix the test process died withSTATUS_ACCESS_VIOLATION; after it, the test passes (10 runs out of 10).Results:
cargo test -p victory-loader --lockedpasses.-D warningsis clean with and without--all-features, apart fromdescriptor_sites.rs:277, which is already failing onmainand which #169 fixes.🤖 Generated with Claude Code
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.