fix(loader): prepare no longer overflows on RVAs past 4 GiB #91
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!91
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-91"
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?
@Caasares on GitHub · 2026-11-27 17:53 UTC · original
Caasares:fix/pe-prepare-rva-overflow→main· +101 −6 · 1 files · 1 commits · closed without mergingBug
victory_loader::prepareadds header-supplied RVAs with plain+, in two places:dir64_relocations: eachIMAGE_REL_BASED_DIR64target ispage + offset, wherepageis the relocation block's page RVA andoffsetis 12 bits.prepare: the TLS callback field's RVA istls.directory_rva + 24.Impact
For a malformed image either sum can pass
u32::MAX, andImageInfo::parseaccepts both inputs:0xFFFFF001with offset0xFFF(target0x1_0000_0000);0xFFFFFFE8in a section that ends at the top of the 32-bit RVA space.A debug build panics (
attempt to add with overflow). A release build wraps silently, so the relocation target becomes a wrong RVA. A wrapped TLS field RVA could also match an unrelated relocation entry and clear it.Valid images are not affected.
Root cause
Unchecked
u32addition on values read from the image header and relocation table.Fix
dir64_relocationsskips an entry whose target does not fit in au32(checked_add), instead of wrapping.checked_add. If it does not fit, no relocation can point at the field, so nothing is cleared.Changes are confined to
crates/victory-loader/src/prepare.rs.How it was tested
Two regression tests in
prepare.rs, each built from a crafted image:relocation_targets_past_the_top_of_the_rva_space_are_skippedtls_directory_at_the_top_of_the_rva_space_is_preparedBoth fail on
mainwithattempt to add with overflowand pass with this change.cargo test -p victory-loader --locked: all tests pass (45 library tests and both integration tests).cargo test --workspace --locked --no-fail-fast: the only failures are twovictory-gpuindirecttests, which already fail onmainand are not touched here.cargo clippy -p victory-loader --locked -- -D warningsand the same with--all-features: clean.--all-targetsreports fourtransmutelint errors inwrite_sites.rsthat already exist onmain. This change adds none.rustfmt --checkis clean forprepare.rs. The repository'sapps/already has formatting differences onmain, which this change does not touch.A mutation run of about 60,000 corrupted images through
ImageInfo::parseandpreparefound no other panic.@cloph-dsp on GitHub · 2026-11-28 00:40 UTC · original
Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):
95b990d39a07685b77a5f89492bb705d62d23bbc, merge base29d8dbf7d9892ceb8bec378a9dbc3c4f2931b745.cargo test --locked -p victory-loader --lib -- prepare::tests::relocation_targets_past_the_top_of_the_rva_space_are_skipped --exact --test-threads=1 --quiet→ 1 passed, 0 failed, 44 filtered, exit 0.git grep -Ffor the test name on the merge base returned no hits (test is new on this PR);git diff --check 29d8dbf7 HEADclean (1 file, +101/-6).CARGO_TARGET_DIR(never shared) withCARGO_BUILD_JOBS=2.AI-assisted (Hy4 flash).
@trustno1-coder on GitHub · 2026-11-28 02:49 UTC · original
Merged into main (
8fc2254) and shipped in v2026.11.27.10. The commit keeps you as its author, so it counts toward the contributors list. GitHub shows this as closed rather than merged only because the commits were applied on top of the newest main (new commit IDs). Thank you!Pull request closed