crash: prevent secondary faults and overflow panics in VEH and exception reporter #679
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
hle
input
INTEL
lighting
linux-proton
memory
MULDER
needs-info
needs-logs
needs-rebase
NVIDIA
performance
post-merge
pr-diagnostics
pr-docs
pre-merge
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
relevance
high
relevance
low
relevance
medium
relevance
very-high
rendering
report
roadmap-proposal
saves
series-s
shaders
startup
status
blocked-by-rework
status
needs-test-report
status
needs-triage
status
ready-for-review
status
stale
status
superseded
status
wip
tools
ui
upstream
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!679
Loading…
Reference in a new issue
No description provided.
Delete branch "MasterWolf/Darner:pr/post-merge-crash-handler-safety"
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?
Not run in the game (verified via
cargo test,cargo clippy, andcargo buildon85107c7; VEH/stack-unwind/C++-throw edge cases covered by unit tests).Contributor role (optional)
What it changes
post-merge: read fromcrates/darner-loader/src/crash.rs(28a9b42):emulate_amd_onlyreads 3 bytes atcontext.Rip(code.cast::<[u8; 3]>().read_unaligned()) before checkingroomto the end of the page, skipsclwb_lenwhenn < 15, passes the raw pointer tosse4awithout bounds checks, and computes((limit - *base) / 64 + 1) * 64(panics in debug when*base == 0 && limit == u64::MAX). A fault near a page end before an unmapped page causes a secondary AV inside the VEH.unwind_intochecksrsp + 8 > highwithout checked addition; corruptedRspnearusize::MAXpanics in debug across the VEH/UEF FFI boundary or wraps in release and readsrsp.throwndereferencesp[2] + 12,types,p[1], and descriptor strings with raw pointers; MSVC C++ rethrows (throw;wherep[1] == 0 && p[2] == 0) or invalid exception records crash inside the exception reporter before logs are written.This PR:
n = room.min(bytes.len())page-bounded bytes first inemulate_amd_only, matchesbytes.get(..3), uses.wrapping_mul(64), and passes&bytes[..n]to bounds-checked slice versions ofclwb_lenandsse4a(removing then >= 15gate onclwb_len).unwind_intowithrsp.checked_add(8).is_none_or(|end| end > high).thrownusingread_memory-backedread_u32/read_usize/read_cstrhelpers, guardingp.len() < 4 || p[2] == 0,count == 0, andp[1] != 0.unwind_into_stops_cleanly_when_rsp_near_usize_max,clwb_len_and_sse4a_handle_short_page_tail_slices,thrown_handles_rethrow_and_invalid_pointers_safely).How it was tested
85107c7(onpost-merge28a9b42)cargo test --offline -p darner-loader --lib crash—3 passed; 0 failed(0.00s)cargo clippy --offline -p darner-loader --tests— passed (0new warnings; 4 pre-existing)cargo build --offline -p darner— passed (7.25s)cargo build,cargo test,cargo clippyChecklist
cargo clippy, andcargo build).post-merge.Checked for overlap
[pr-fix][loader] crash: prevent secondary faults and overflow panics in VEH and exception reporterto crash: prevent secondary faults and overflow panics in VEH and exception reporterView 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.