Repository navigation
Conversation
|
Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on clean Three more passing tests than main, so the PE-loader refusals for IAT and TLS-index writes inside the headers are exercised here; nothing else changes verdict. Tree restored afterwards (md5 and a full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it. |
|
Linux / AMD RDNA3 datapoint. Merged state: head Full suite, Not tested: retail titles (none here), Windows, RDNA4. Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting. |
|
Thanks for the independent verification runs (@dcastell1, @SlopTart). This PR still needs the two retail If someone with a Series title can run: # on main, then on this PR head (clean tree, no uncommitted changes)
cargo build --release -p xcl
.\scripts\smoke.ps1 -Game '<Series title folder>' -Seconds 60and paste both No game data needed in the comment — only the smoke block text. |
A crafted image whose FirstThunk or TLS AddressOfIndex lands below SizeOfHeaders would overwrite the mapped headers before they are re-read. Reject those write targets in pe.rs once (PeError::HeaderWriteTarget), including delay-load HMODULE slots. Fixes xcl-dev#836 Assisted-by: Cursor Auto (Composer) Co-authored-by: Cursor <cursoragent@cursor.com>
46376c5 to
6ce1240
Compare
|
Regression run of Against the limits in CONTRIBUTING.md: 101 % of AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, AI use: Claude Code (Claude Opus 5.5) built both trees and ran |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Thanks @Toons29 — pasted both of your |
|
CI is stuck on |
|
NVIDIA test report for
AI-assisted (Claude Code, Claude Opus 5.5). Synthetic tests only; no title run. |
|
Thanks @upipibi — copied the workspace counts for |
…xcl-dev#1203) Port the combined final shape (pr1203head = c97bd9f, child of pr854head = 6ce1240; both still OPEN vs upstream/main, merge-base false): PeError::HeaderWriteTarget + ensure_data_write_rva(rva, width) with the whole-width [headers, image) guard, checked on the import-thunk IAT slot (8B), the delay-load HMODULE slot (8B), and the TLS AddressOfIndex slot (4B), plus pe_with_headers + 6 boundary tests as-is. Reconcile: tree already has checked_add(2) from step-82 where xcl-dev#854's base shows wrapping_add; kept checked_add and added the ensure call on top. Pre-existing saturating_add(8) outside-image guards stay; ensure adds the header-floor and the straddle (checked_add(width)) ceiling. Failing-first: new tests reference HeaderWriteTarget/ensure, both absent pre-fix (E0599); header payloads that pre-fix mis-read as BadRva(0x8000…) now report HeaderWriteTarget(0x80). Gates: both checks 0 errors; lib 743/0/1 (+6); title 12 unique FAILs all D3D12.X GPU-only 0 non-GPU; retail SIGSEGV +0x2237320 exit 139 stubs 20.
gut0to
left a comment
There was a problem hiding this comment.
AI-assisted review: I inspected the diff and the loader write sites; I did not run tests.
| /// Refuse an RVA the loader would write into when it still needs the headers intact | ||
| /// (IAT thunks, delay-load module handles, TLS `AddressOfIndex`). Targets must lie in | ||
| /// `[size_of_headers, size_of_image)`. | ||
| fn ensure_data_write_rva(&self, rva: u32) -> Result<(), PeError> { |
There was a problem hiding this comment.
Could this validate the full write width, not only the starting RVA? thunks accepts an IAT slot at SizeOfImage - 4 because that start is in range, but the loader writes an entire u64 there (loader.rs IAT and delay-load module-handle writes); similarly, the TLS index write is a u32. A malformed image can therefore pass this new guard and make the loader write past the mapped image. Please use a checked [rva, rva + width) range check for each target and add upper-bound cases where the slot starts inside the image but ends beyond SizeOfImage. AI-assisted review: I inspected the diff and the loader write sites; I did not run tests.
There was a problem hiding this comment.
The start-only check on this PR is the header case (#836). The full write is checked in #1203, which is the next commit on this branch.
ensure_data_write_rva(rva, width) requires [rva, rva + width) to sit in [SizeOfHeaders, SizeOfImage), with checked_add so the end cannot wrap. Call sites pass the width the loader actually stores: 8 for an IAT slot and a delay-load HMODULE, 4 for the TLS AddressOfIndex.
Upper-bound tests on that PR:
import_address_table_straddling_image_end_is_error— IAT atSizeOfImage - 4, rejected asBadRvatls_index_straddling_image_end_is_error— TLS index atSizeOfImage - 2, rejected asBadRva
There is no separate delay-load HMODULE straddle test; that slot uses the same width-8 check as the IAT.
|
Independent desktop NVIDIA verification of PR #854 at head Environment
Targeted tests & build (
|
| Command | Result |
|---|---|
cargo test --release -p xcl --lib -- --nocapture import_address_table_in_headers_is_error tls_index_in_headers_is_error delay_import_module_handle_in_headers_is_error write_targets_at_size_of_headers_are_accepted (3 consecutive runs) |
4 passed; 0 failed; 0 ignored; 719 filtered out × 3 (0.00s, 0.00s, 0.00s, 0 skipped) |
cargo test --release -p xcl --lib pe:: -- --nocapture (3 consecutive runs) |
14 passed; 0 failed; 0 ignored; 709 filtered out × 3 (0.00s, 0.00s, 0.01s, 0 skipped) |
cargo build --release -p xcl |
Clean build (55.45s, exit 0, 0 new warnings in pe.rs) |
Paired quiet 60 s retail smoke (title: 29640639)
(Note: scripts/smoke.ps1 at 47efa2ec predates 9683e7a6 and printed the local folder basename on title:; replaced below with the standard 9683e7a6 title hash 29640639, with all measured fields verbatim.)
Exact parent & merge-base (47efa2ecea0a12934719ae69b81930cf02a4b1c3):
xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1527 (PresentX 1527)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14723 MB
PR #854 (6ce1240498cd787448963da24cd8f5e892feb0da):
xcl-smoke v1
commit: 6ce1240498cd787448963da24cd8f5e892feb0da
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1586 (PresentX 1587)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14712 MB
Limits of coverage
- All 4 new
#836header-write rejection / boundary tests (import_address_table_in_headers_is_error,tls_index_in_headers_is_error,delay_import_module_handle_in_headers_is_error,write_targets_at_size_of_headers_are_accepted) plus the fullpe::suite (14/14,0skipped) passed3/3. - The 60 s retail smoke confirms real retail PE loading and runtime execution remain completely unaffected (
0device removals,0crashes, steady 60 Hz); single-run frame/commit delta vs. parent reflects normal startup variance.
AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
|
Thanks @Decodere. The release The smoke blocks stay in this comment. |
|
merge-check |
|
merge-check claim |
|
merge-check |
|
merge-check |
|
#1203 (same author) is stacked on this PR: it contains this commit and adds a width check on top, so it is not a duplicate and this PR should land first. #1367 bounds IAT/HMODULE/relocation writes against SizeOfImage in loader.rs and pe.rs but does not refuse targets inside the headers, so it does not cover #836. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
Fixes #836.
A crafted PE whose import address table, delay-load HMODULE slot, or TLS
AddressOfIndexlands belowSizeOfHeaderswould let the manual mapper overwrite its own headers before later steps re-read them. Reject those directory-derived write targets once inpe.rs(PeError::HeaderWriteTarget). Targets must lie in[size_of_headers, size_of_image).What is in it
crates/xcl/src/pe.rs:ensure_data_write_rva, checks in import thunks / delay-load HMODULE / TLS index parsing, and unit tests for IAT, delay-load HMODULE, and TLS index inside the headers plus theSizeOfHeadersboundaryTested
6ce1240498cd787448963da24cd8f5e892feb0daas-is, base47efa2e): NVIDIA RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11, debug, aftercargo build --workspacecargo test --workspace --no-fail-fast -- --test-threads=4 --skip hle::xaudio2: 736 passed, 0 failed, 41 ignored. End-to-end title tests passed.SKIPPED: 2 GPU tests, bothno wave64on this card.hle::xaudio2was skipped because those tests fail or hang on this machine onmaintoo; this PR does not touch it.6ce1240498cd787448963da24cd8f5e892feb0da, RTX 4060 8 GB (Ada, wave32), driver 32.0.16.2114, i5-11400F, 32 GB, Windows 11 build 26200, rustc 1.100.0, DXC 1.9.2609.5: the four header-write tests passed 3/3 (4 passed, 0 failed), andcargo test --release -p xcl --lib pe::passed 3/3 (14 passed, 0 failed).cargo build --release -p xclwas clean.cargo test -p xcl --lib pe::tests: 14 passed (includes the delay-load HMODULE case). @DavidM1911 also rancargo test -p xcl --libafter merging the branch with then-currentmain(RTX 3060 Ti): passed, with a note about intermittent Test suite: parallel cargo test intermittently dies with 0xc0000005 (hle::d3d12x queue_tests × list_x race) #1978 under parallel scheduling.Regression run
scripts/smoke.ps1from @Toons29 (RX 9070, 60 s, same title/time; blocks as printed):Not tested
hle::xaudio2on the RTX 3070 report (pre-existing onmainfor that machine)AI use
pe::tests and drafted the report