loader/crash: fix unwritable CLZERO fallthrough AV, page-boundary ove… #528

Open
pug205gti6 wants to merge 1 commit from upstream-pr/528 into main
pug205gti6 commented 2026-11-25 02:00:01 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by pug205gti6 on 2026-11-25T02:00:01Z.


…rreads, and thrown() NULL derefs

Fix three VEH / crash-reporter fault hazards in crates/victory-loader/src/crash.rs:

  1. In emulate_amd_only, verify the 64-byte clzero target line is committed and writable via VirtualQuery before calling write_bytes(0, 64), so an unwritable clzero that console_insn::emulate rejected does not fall through and trigger a nested Access Violation inside the VEH.
  2. Copy page-bounded instruction bytes (room = 0x1000 - (Rip & 0xfff)) before inspecting [0x0f, 0x01, ...] or clwb_len, and pass the bounded slice &bytes[..n] into a safe slice-based sse4a(&[u8], ...) so 1–6 byte illegal instructions at the end of a page adjacent to an unmapped/no-access page cannot fault while decoding.
  3. In thrown(), handle MSVC throw; rethrows (p[2] == 0 || p[3] == 0), guard rva(types) == 0 / zero catchable type count before calling name(0), and require p[1] != 0 before reading std::exception's message pointer.

Add synthetic unit tests for all three failure modes.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6595404946 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/528). Originally posted by [pug205gti6](https://github.com/pug205gti6) on 2026-11-25T02:00:01Z. --- …rreads, and thrown() NULL derefs Fix three VEH / crash-reporter fault hazards in `crates/victory-loader/src/crash.rs`: 1. In `emulate_amd_only`, verify the 64-byte `clzero` target line is committed and writable via `VirtualQuery` before calling `write_bytes(0, 64)`, so an unwritable `clzero` that `console_insn::emulate` rejected does not fall through and trigger a nested Access Violation inside the VEH. 2. Copy page-bounded instruction bytes (`room = 0x1000 - (Rip & 0xfff)`) before inspecting `[0x0f, 0x01, ...]` or `clwb_len`, and pass the bounded slice `&bytes[..n]` into a safe slice-based `sse4a(&[u8], ...)` so 1–6 byte illegal instructions at the end of a page adjacent to an unmapped/no-access page cannot fault while decoding. 3. In `thrown()`, handle MSVC `throw;` rethrows (`p[2] == 0 || p[3] == 0`), guard `rva(types) == 0` / zero catchable type count before calling `name(0)`, and require `p[1] != 0` before reading `std::exception`'s message pointer. Add synthetic unit tests for all three failure modes.
Headache3318 commented 2026-11-25 10:11:10 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Headache3318 on 2026-11-25T09:22:16Z.


Independent verification: PR #528 merges cleanly onto main, no conflicts. Build: success (8.61s). Tests: 253 passed, 1 failed (pre-existing Wine issue in victory-hle only_loopback_is_reachable test — confirmed failing on main without PR). PR modifies crates/victory-loader/src/crash.rs (144 insertions, 34 deletions) to fix CLZERO fallthrough AV, page-boundary overreads, and thrown() NULL derefs. No new build errors or test regressions. Machine: Arch Linux, kernel 7.3.5-arch1-1, 3x RTX 4090 driver 620.73.04, Proton, AI-assisted.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7158238467 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/528#issuecomment-7158238467). Originally posted by [Headache3318](https://github.com/Headache3318) on 2026-11-25T09:22:16Z. --- Independent verification: PR #528 merges cleanly onto main, no conflicts. Build: success (8.61s). Tests: 253 passed, 1 failed (pre-existing Wine issue in victory-hle only_loopback_is_reachable test — confirmed failing on main without PR). PR modifies crates/victory-loader/src/crash.rs (144 insertions, 34 deletions) to fix CLZERO fallthrough AV, page-boundary overreads, and thrown() NULL derefs. No new build errors or test regressions. Machine: Arch Linux, kernel 7.3.5-arch1-1, 3x RTX 4090 driver 620.73.04, Proton, AI-assisted.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/528:upstream-pr/528'
git switch 'upstream-pr/528'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/528'
git switch 'upstream-pr/528'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/528'
git switch 'upstream-pr/528'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/528'
git switch 'main'
git merge --squash 'upstream-pr/528'
git switch 'main'
git merge --ff-only 'upstream-pr/528'
git switch 'main'
git merge 'upstream-pr/528'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!528
No description provided.