Repository navigation
Loader (diagnostics): VICTORY_POKE writes through the page's protection - #2659
kotekompotek wants to merge 1 commit into
Conversation
|
Automated triage for the maintainers. Recommended for a maintainer's look. With the two unrelated GPU commits dropped, the branch now holds only the On your reply: confirmed. The diff against Generated by Claude Code |
The poke wrote the byte with a raw volatile store, so listing an rva in the title's read-execute .text (e.g. nopping an assert's int3) raised an access violation in the host itself before the title ran. The write now goes through a loader helper that makes the page writable for the write, restores its protection, and flushes the instruction cache on executable pages. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
af73105 to
e8ccc39
Compare
|
Code review and Windows 11 verification at head
Looks clean and ready to merge. |
…h the page's protection
|
NVIDIA full-suite run, to go with the reports above by fuzeofficlal, since none of them names a GPU run. Tested exact head Tested
Not tested
AI use
|
fuzeofficlal
left a comment
There was a problem hiding this comment.
Reviewed and verified at head e8ccc396 against origin/main (63bcca43) on Windows 11 (debug & release, default & --all-features):
- Design & correctness:
victory_loader::write_title_byte(crates/victory-loader/src/crash.rs:54-110), its re-export (crates/victory-loader/src/lib.rs:45), and its callerpoke(apps/victory/src/run.rs:286-305) stay strictly gated behind#[cfg(all(windows, feature = "diagnostics"))].- Single-byte writes cannot cross a page boundary;
VirtualQuerysafely rejects uncommitted memory (queried == 0 || info.State != MEM_COMMIT); non-writable pages preserve executability (PAGE_EXECUTE_READWRITEwheninfo.Protect & 0xF0 != 0, elsePAGE_READWRITE) on a 4 KiB-alignedVirtualProtect, handleVirtualProtectfailure cleanly without writing, restoreoldprotection afterward, and flush the instruction cache on executable pages. - Non-blocking observations:
- Because
base_protect = info.Protect & 0xFFmasks offPAGE_GUARD, aPAGE_READWRITE | PAGE_GUARDpage enters the writable fast path and raisesSTATUS_GUARD_PAGE_VIOLATION(0x80000001), whereasPAGE_READONLY | PAGE_GUARDgoes throughVirtualProtectand restoresPAGE_READONLY | PAGE_GUARDcleanly. Checkinginfo.Protect & PAGE_GUARD == 0inwritablewould cover that uniformly if ever hit outside normal PE sections. - An already-writable executable page (
PAGE_EXECUTE_READWRITE/PAGE_EXECUTE_WRITECOPY) takes the fast path without callingFlushInstructionCache(benign on x86-64). - Adding a small unit test exercising
PAGE_READONLY,PAGE_EXECUTE_READ, andMEM_RESERVEwould lock in protection restoration.
- Because
- Verification:
- Clean
git merge-treeagainstorigin/main(63bcca43);cargo xtask policy(190 files ok);cargo clippy -p victory-loader -p victory --all-targets --locked -- -D warningsclean with default features and--all-features. cargo test -p victory-loader --locked: 35 unit + 4 integration passed (default), 37 unit + 4 integration passed (--all-features, both debug and--release);cargo check -p victoryclean in both dev default and--release --all-features.- Exercised
write_title_bytedirectly againstPAGE_READWRITE,PAGE_READONLY,PAGE_EXECUTE_READ,PAGE_NOACCESS,MEM_RESERVE, andPAGE_READONLY | PAGE_GUARDallocations on Windows 11—all wrote and restored exact original protections (and returnedfalseonMEM_RESERVE).
- Clean
LGTM.
Summary
VICTORY_POKEwrote the byte with a raw volatile store, so poking an rva in the title's read-execute.text(e.g.:0x90over an assert'sint3) raised an access violation in victory.exe itself (0xc0000005atvictory.exe+0x524eb) before the title ran.victory_loader::write_title_byte:VirtualQuerythe address,VirtualProtectthe page writable for the write, restore its protection, flush the instruction cache on executable pages. Committed-writable pages take the same fast path as before.run.rs::pokenow goes through the helper; doc updated (code pages work too).Test plan
VICTORY_POKE=0x1ce6e13:0x90on the Series 1.0.2.1 image: previously AV'd the host insidepoke; now writes through and the run continues past the site.cargo check -p victory --features diagnostics,cargo clippy -p victory-loader -p victory --all-targets --all-features --locked -- -D warningsNote: for skipping
int3asserts entirely, #2644'sVICTORY_STEP_OVERis the better tool (no writes needed); this fixes poke for data bytes on read-only pages and for anyone who still wants code patching.Generated with Devin