Loader: skip DIR64 relocation addresses that overflow u32 #3241
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3243"
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 Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T14:22:14Z.
A malformed
BASERELOCblock puts the page RVA nearu32::MAX;page + u32::from(e & 0xFFF)indir64_relocationsthen panics in debug builds and wraps in release ones, returning a relocation address that was never in the image.reloc_addressnow useschecked_add, and an entry that does not fit is skipped on its own, so a bad page base does not throw away the well-formed entries after it.endis clamped tobytes.len()withsaturating_add; valid files are unchanged, since the directory is inside the file.relocation_addresses_past_u32_are_skippedcovers0x1000 + 0x0A, the last address0xFFFF_FFF0 + 0xF, the overflowing0xFFFF_FFF0 + 0x10, and the type/offset split0xA000 -> 0x2000.cargo test -p victory-loader: 35 passed, 1 failed. The failure isprepare::tests::windows_assigns_static_tls_to_a_prepared_dll("the test binary uses static TLS"); it fails identically with this patch stashed, so it is local to this machine.cargo clippy -p victory-loader --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.The other two points in #2411 cannot fail on the 64-bit hosts VIctory builds for:
start + sizeandat + blockare ausizeplus au32, and reads past the end already stop throughlayout::read_u32andbytes.get. #2418 guards those as well, with aproposed closetriage for that reason; thereloc_addresschange is the behavioural difference. The issue's proposed arithmetic came from @pushkarreddyy.Fixes #2411.
Coordination
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T14:30:49Z.
Review: APPROVED
Reviewed the diff and verified locally on Windows 11 x64:
eloc_address and clamping end with saturating_add(...).min(bytes.len()) cleanly prevents debug overflow panics and release wraparound on malformed BASERELOC blocks.
eloc_address.
elocation_addresses_past_u32_are_skipped).
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T15:39:54Z.
Thanks for catching this.
2b898b6moves the iterator's doc comment back todir64_relocationsand putsconst DIR64on its own line. The patch changes comments and whitespace. The loader builds with all features.Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-27T01:42:31Z.
Independent local verification (Windows, Rust 1.100.0/MSVC, synthetic inputs only, no game data).
2b898b6; merge base withorigin/main:63bcca4.cargo test --locked -p victory-loader --lib -- prepare::tests::relocation_addresses_past_u32_are_skipped --exact --test-threads=1 --quiettest result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 35 filtered out, exit 0.git diff --check 63bcca4 HEAD: exit 0, clean.git grep -n relocation_addresses_past_u32_are_skipped 63bcca4-> 0 hits; the test is new on this PR.Caveat: this run exercises the extracted
reloc_addresshelper, notdir64_relocationsend-to-end; no malformed-BASERELOC fixture was replayed here.AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only loader test). No game data, assets or DRM involved.
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-27T04:04:43Z.
@cloph-dsp Thank you for the independent local verification on
2b898b6!@Marvisak Please review and merge this PR when convenient. Testers on untested setups are welcome to test.
AI-assisted: yes (Gemini 4 Neon)
Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-27T23:21:56Z.
NVIDIA full-suite run, to go with the reports above by cloph-dsp, since none of them names a GPU run. Tested exact head
2b898b6(on its base63bcca4).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.relocation_addresses_past_u32_are_skipped.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-28T07:33:21Z.
@futurepro62 Thank you for running the full RTX 5070 Ti test suite on
2b898b6(867 passed, 0 failed, 10 ignored, includingrelocation_addresses_past_u32_are_skipped)!@Marvisak Please review and merge this PR when convenient (CI is green). Testers on untested setups and GPU models are welcome to test.
AI-assisted: yes (Gemini 4 Neon)
Imported from Marvisak/VIctory. Originally posted by Sal-zinho on 2026-11-28T16:58:40Z.
Review: COMMENTED
Tested on Windows 11, x86_64-pc-windows-msvc, Rust 1.98.1.
Tests: All 36 unit tests pass (including the new relocation_addresses_past_u32_are_skipped). The pre-existing loads_binds_and_calls_probe failure (OS error 2) is unchanged from main and unrelated to this PR. windows_assigns_static_tls_to_a_prepared_dll passes here.
Clippy: Clean, no warnings.
Formatting: Minor nit — prepare.rs:142 has a formatting diff with the pinned rustfmt 1.98.1 (the .saturating_add().min() chain wants to be broken across lines). crash.rs, lib.rs and publish.rs fail fmt --check identically on main, so those are pre-existing and not from this PR.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T17:12:25Z.
Thanks, @Sal-zinho. The wrapping in
prepare.rsnow matches the pinned rustfmt in210dea6. I checked the whitespace-only diff and compiled the loader with all features.Windows CI passed on this exact head. The next step is maintainer review.
AI-assisted with OpenAI Codex.
Imported from Marvisak/VIctory. Originally posted by dux14 on 2026-11-29T05:27:05Z.
reloc_addresswithchecked_addfixes the only overflow that can actually occur,page + (e & 0xFFF). It skips just the bad entry, so well-formed entries later in the block still apply. The unit test covers the boundary (0xFFFF_FFF0+0xFisSome,+0x10isNone) and the type/offset split without needing a PE fixture. Theendclamp changes nothing on 64-bit hosts, so it can stay as hardening or be dropped. LGTM.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.