Loader: skip empty executable sections in tls::redirect and add tls.rs unit tests #1192
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1192"
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 geiyiliyabumo on 2026-11-24T16:23:11Z.
Summary
Closes #938
Full verification details and change notes are documented in #938 (commit
02ea74c, based onmainffe310e).Verification (Windows 11 x64 MSVC)
rustfmt --edition 2024 --checkon edited files: PASScargo xtask policy: PASS (zero game files/data)cargo clippy --all-targets --locked -- -D warnings(default +--features diagnosticswhere applicable): PASSAI-assisted; synthetic tests only, no game files.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T16:27:14Z.
Review: APPROVED
Tested head
02ea74c(fast-forward onmainffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC):cargo test -p victory-loader: 35 unit + 2load_probe+ 1title_dllspassed, 0 failedcargo clippy -p victory-loader --all-targets: 0 warningscargo xtask policy: okSolid bounds/overflow fixes and test coverage for
tls.rsandstacks.rs. Approving.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by Kal0s-design on 2026-11-24T16:27:27Z.
Independent check of
02ea74c, merged locally ontomainffe310e(merge was clean). Windows 11, MSVC, Rust 1.98.1 as pinned.cargo test -p victory-loader --locked: lib 35 passed, 0 failed; 2 + 1 integration tests pass. The lib suite was run 15 more times: 15/15 green.cargo clippy -p victory-loader --all-targets --locked -- -D warnings, with and without--all-features: clean.tls.rstest module on top ofmain's production code (nothing else changed). 4 tests fail on 3 of 3 runs:a_directory_outside_the_image_is_an_error,an_index_no_loader_assigns_is_an_error,an_index_outside_the_image_is_not_written,an_empty_executable_section_does_not_stop_the_rest. All pass with the PR's code.Not covered: the
stacks.rschange (delaysis a new function, so its test cannot run againstmain; I only ran it on the PR); nothing was run against a real title.AI-assisted: yes. Every number above is from my own runs.
Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T18:00:25Z.
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
02ea74c:cargo test -p victory-loaderpasses, 38 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:18:09Z.
Automated triage for the maintainers.
Merge candidate. Update after your latest push (
ee9defc): the point from the last triage is addressed.tls::redirect(crates/victory-loader/src/tls.rs) now takes the section length asvirtual_size, orfile_sizewhen that is 0, matching howvictory_pemaps sections (crates/victory-pe/src/image.rs), and skips a section only when both are 0. The new testan_executable_section_with_zero_virtual_size_uses_its_file_sizecovers the raw-data-with-VirtualSize-0 case, and the SIB nit inother_nine_byte_windows_are_left_aloneis fixed ([rsi], no displacement).The rest is unit tests for
patch,thunks,nearandredirecton a synthetic image, which check the right things (per-register call targets, near-misses, thunk bytes, the slot the patched load returns). Onlytls.rschanges; no dependencies.CI: passing (
check).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-25T01:55:21Z.
Rebased cleanly onto \main\ (\
ccfb029). \cargo test -p victory-loader --locked\ (51 passed, 0 failed), \cargo test -p victory-loader --locked --features diagnostics --lib stacks::tests\ (3 passed, 0 failed), \cargo clippy -p victory-loader --all-targets --locked -- -D warnings, and \cargo xtask policy\ all pass.[PR #1192] Loader: fix 4 bounds/overflow bugs in tls.rs and stacks.rs with unit teststo [PR #1192] Loader: skip empty executable sections in tls::redirect and add tls.rs unit testsImported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-25T04:00:39Z.
Updated per triage feedback: reverted \stacks.rs\ completely back to \main\ and dropped the three redundant
edirect\ range guards and their guard-only tests, keeping only the empty-executable-section (\len == 0) skip hardening and the \patch/\ hunks\ unit tests in \ ls.rs. Rebased onto \main\ (\
940d32f); \cargo test -p victory-loader --locked\ (48 passed, 0 failed), \cargo clippy -p victory-loader --all-targets --locked -- -D warnings, and \cargo xtask policy\ all pass.Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-25T07:55:49Z.
Updated \ ls::redirect\ per triage feedback (head $sha): fall back to \ile_size\ when \irtual_size == 0\ (matching \ictory_pe::image::rva_to_file_offset) and skip only when both are 0, added a synthetic regression test for \irtual_size == 0\ with non-zero \ile_size, and fixed the \
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:25:43Z.
Code review and Windows 11 verification at head
ee9defcd5490merged cleanly ontomain(63bcca43c6a0):crates/victory-loader/src/tls.rs:51-61, 182-530):virtual_sizeif non-zero elsefile_size) is0cleanly avoidsVirtualProtect(..., 0, ...)failing withERROR_INVALID_PARAMETERand aborting static TLS redirection.VirtualAlloctests thoroughly cover real relocated execution across GPRs, negative 9-byte windows, overlapping matches, thunk layout, 1 GiBnearbounds,virtual_size == 0fallback, and empty executable sections.#188also introduces#[cfg(test)] mod testsat the bottom oftls.rs(minor text-only merge conflict; production changes are orthogonal and compose cleanly).cargo xtask policy:191 files ok;cargo clippy --locked -p victory-loader --tests -- -D warnings: 0 warningscargo test --locked -p victory-loader: 50/50 passed (46 unit including all 10tls::tests+ 4 integration).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.