Skip to content

PE loader: reject unreadable export forwarders - #1134

Open
anakatt wants to merge 1 commit into
xcl-dev:mainfrom
anakatt:pe/reject-unreadable-forwarders
Open

anakatt wants to merge 1 commit into
xcl-dev:mainfrom
anakatt:pe/reject-unreadable-forwarders

Conversation

@anakatt

@anakatt anakatt commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

I reject an unreadable PE export forwarder instead of treating its RVA as an ordinary export address. Previously, a missing string terminator caused the forwarder data's address to enter the owned export tables.

What is in it

  • pe.rs: propagate a failed forwarder-string read as None, with a contract comment.
  • Synthetic regression covering valid and unterminated forwarders in both file and mapped layouts, including named and ordinal OwnedExports lookups.

Tested

I ran debug tests on Windows 11 Pro ARM64 10.0.26100.1742 in UTM (4 GiB RAM, virtual virt-10.0 CPU, Red Hat VirtIO GPU DOD), using Rust 1.100.0 x86_64-pc-windows-msvc and Visual Studio 2022 Build Tools. The guest used main 47efa2ecea0a12934719ae69b81930cf02a4b1c3 plus the source changes committed as aeb5ca72aa4b6f7fc4ecaad2c8225c1dff59e6e7.

cargo test --locked -p xcl --lib pe::tests::unterminated_forwarders_are_not_export_addresses -- --exact:

  • Before the fix: 0 passed, 1 failed, 0 ignored, 719 filtered out; the unterminated forwarder returned Some(Rva(4156)) instead of None.
  • After the fix: 1 passed, 0 failed, 0 ignored, 719 filtered out; no SKIPPED output.

Not tested

I have not run the full workspace suite, native x64 Windows hardware, D3D12 GPU execution or a real game title. This verifies PE parsing and owned export lookup, not loading a malformed DLL into a game process.

Regression run

Not run. This remains a draft pending the required real-title xcl-smoke blocks from main and this PR's clean head, using the same title and duration.

AI use

I used omp (openai-codex/gpt-6-astra) to investigate, implement the fix and regression, run the Windows test, and prepare this PR.

An export RVA inside the export directory denotes a forwarder string.
When that string could not be read, export_target passed None to the
ordinary-RVA fallback and exposed the string's address as an export.

Return None instead. A synthetic regression checks terminated and
unterminated forwarders in file and mapped layouts, including both named
and ordinal OwnedExports lookups.

Windows 11 ARM64 VM, x64 MSVC rustc 1.100.0: the new regression failed
before the fix (Some(Rva(4156)) instead of None), then passed: 1 passed,
0 failed, 0 ignored, 719 filtered out. Full GPU suite, native x64 hardware
and real-title smoke runs remain outstanding.

Assisted-by: omp (openai-codex/gpt-6-astra)
@anakatt
anakatt marked this pull request as ready for review November 24, 2026 12:26
@eizispark

Copy link
Copy Markdown
Contributor

Hardware test report — commit aeb5ca7

Verified clean merge with main (47efa2e) on aeb5ca72aa4b6f7fc4ecaad2c8225c1dff59e6e7: pass.

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11, rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profile
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 742 passed, 0 failed, 41 ignored (GPU tests skipped on this adapter: none), including pe::tests::unterminated_forwarders_are_not_export_addresses and all 11 pe::tests

Regression run
main (47efa2e):

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1677 (PresentX 1677)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14853 MB

PR (aeb5ca7):

xcl-smoke v1
commit: aeb5ca72aa4b6f7fc4ecaad2c8225c1dff59e6e7
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1679 (PresentX 1679)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14856 MB

Not tested

  • wave32-only GPUs (NVIDIA / Intel); retail run under XCL_D3D12_DEBUG=1; gameplay past the menus

AI use: Antigravity (Google DeepMind), Gemini (exact version string not exposed in runtime environment) — ran the workspace test suite and 60 s retail smoke check on the hardware above and formatted this report.

@JoaoPauluu

Copy link
Copy Markdown

A run on Linux under Wine.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257, DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. aeb5ca7 as it is (based on 47efa2e), no uncommitted changes. The lib test binary runs under Wine, one test per process (--exact).
  • pe::tests::unterminated_forwarders_are_not_export_addresses: ok, no SKIPPED.

Not tested

  • whether the new tests fail without the change on this stack; the rest of the suite on this head; a retail title; native Windows.

AI use

  • Claude Code (Claude Opus 5.5) built the head, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…r + ordinal overflow (port upstream xcl-dev#1216 + xcl-dev#1134 + xcl-dev#700)

Port all three complementary single-file pe.rs keepers verbatim
(pe.rs is shared, compiles on Linux — no twin needed):
- xcl-dev#1216: hn.checked_add(2) for the hint/name RVA (was wrapping_add)
  + import_name_at_the_top_of_the_address_space_is_error
- xcl-dev#1134: export_target propagates failed forwarder-string read as
  None (was leaking the RVA as an ordinary export address)
  + unterminated_forwarders_are_not_export_addresses (file+mapped)
- xcl-dev#700: from_pe ordinal loop uses checked_add + break past u32::MAX
  (was debug-panic / release-wrap to shadowing ordinal 0)
  + export_ordinals_past_u32_max_are_skipped

Failing-first: xcl-dev#1134 failed pre-fix (Some(Rva) vs None),
xcl-dev#700 failed pre-fix (attempt to add with overflow); xcl-dev#1216 passes
pre-fix too (0x7FFFFFFF hint mask already bounds hn, so +2 cannot
wrap on this path — ported verbatim for fidelity, zero behavior
change today).

Gates: both cargo checks 0 errors; lib 732/0/1 (+3); title e2e
12 unique FAILs all D3D12.X GPU-only 0 non-GPU (baseline holds);
retail SKIPPED (game drive unmounted this session).
@github-actions

Copy link
Copy Markdown

Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Nov 29, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head aeb5ca7

No open or merged PR makes the same change: the other open PE loader PRs (#700, #1367, #1397 and others) do not touch Pe::export_target, and main still turns an unreadable forwarder string into ExportTarget::Rva pointing inside the export directory.
The fix in pe.rs:export_target (Some(self.cstr_at(rva)?)) drops such an export from OwnedExports instead, and the test covers both File and Mapped layouts. No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

@github-actions github-actions Bot removed the stale No activity for 3 days; closed 4 days later unless something happens label Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants