PE loader: an import name at the top of the address space is an error #1207
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1216"
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 ivall/xcl. Originally posted by Longno242 on 2026-11-24T13:18:56Z.
A named import thunk stores the hint/name RVA. Adding 2 with wrapping turned
0xFFFFFFFEinto RVA 0, so the parser accepted the DOS header (MZ) as the import name instead of rejecting the image.What is in it
crates/xcl/src/pe.rs:checked_add(2)for the import name RVA; unit test with the hint at0xFFFFFFFEinside a high sectionTested
b0a128cb0a128c7503de9c7f2283e6e315a9ead9045f7a1(clean tree)cargo test --workspace -- --test-threads=4: 742 passed, 0 failed, 41 ignored. SKIPPED: 2 GPU tests for no wave64 (expected on this card)SKIPPED: 2 GPU tests for no wave64 (expected on this card)cargo test -p xcl --libon RTX 3060 Ti after merging this head with currentmainlocally: all passed, 0 failed, 27 ignored. The PR head itself is unchanged.Regression run
scripts/smoke.ps1from @Toons29 (RX 9070, 60 s, same title/time; blocks as printed):Not tested
cargo test --workspaceAI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T13:47:12Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:Note: the full
d3d12xlib filter currently aborts with 0xc0000005 on unmodifiedmaintoo (pre-existing, unrelated to this PR); the PR's own tests were run by name and pass.Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:17:22Z.
Regression run of
b0a128c7on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 101 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.Imported from ivall/xcl. Originally posted by Longno242 on 2026-11-25T12:36:36Z.
Thanks @Toons29 — pasted both of your
xcl-smoke v1blocks under Regression run so the description check can see them.Imported from ivall/xcl. Originally posted by Longno242 on 2026-11-25T12:44:05Z.
CI is stuck on
action_required(first-time contributor workflow approval). Smoke + PR description are green; please approve the pending CI workflow when you get a chance.Imported from ivall/xcl. Originally posted by jennydeth on 2026-11-25T12:59:37Z.
Full workspace run (listed under Not tested).
Setup: RTX 3060 12 GB (32-lane waves, driver 32.0.16.2101), Ryzen 5 5600X, 32 GB RAM, Windows 11 build 26300, Rust 1.100.0, DXC 1.9.2609.5, debug build. Head
b0a128c.Result: cargo test --workspace -- --test-threads=4: 742 passed, 0 failed, 41 ignored. SKIPPED: 2 GPU tests for no wave64 (expected on this card).
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
Imported from ivall/xcl. Originally posted by Longno242 on 2026-11-25T13:21:25Z.
Thanks @jennydeth — copied your workspace counts into Tested (742 passed, 0 failed, 41 ignored. SKIPPED: 2 GPU tests for no wave64 (expected on this card)).
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T04:05:26Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by Longno242 on 2026-11-26T12:33:40Z.
Thanks @DavidM1911 — noted the
cargo test -p xcl --libre-check (passed, 0 failed, 27 ignored) under Tested. Head commit is unchanged.Imported from ivall/xcl. Originally posted by coolpersonnn on 2026-11-30T18:59:58Z.
merge-check claim
head:
b0a128c750Imported from ivall/xcl. Originally posted by coolpersonnn on 2026-11-30T19:05:48Z.
merge-check
base:
ff0c364b3dhead:
b0a128c750merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 0 failed, 51 ignored (25 SKIPPED: 22 no wave64, 2 no heap windows, 1 cannot disable the driver cache); failing: none; new test pe::tests::import_name_at_the_top_of_the_address_space_is_error passed
review: Read the full diff (+24/-1 in crates/xcl/src/pe.rs). The claimed wrap-to-RVA-0 bug is unreachable and the new test does not exercise the changed line: on line 420 right above it,
hnis computed as(v & 0x7FFF_FFFF) as u32(31-bit PE32+ Hint/Name RVA), sohn <= 0x7FFF_FFFFalways andhn.checked_add(2)can never overflowu32(max0x8000_0001). In the new testimport_name_at_the_top_of_the_address_space_is_error, putting0xFFFF_FFFEu64in the INT slot produceshn = 0x7FFF_FFFEafter& 0x7FFF_FFFF;self.u16_at(0x7FFF_FFFE)immediately returnsErr(PeError::BadRva(0x7FFF_FFFE))on line 421 before line 424 is ever reached, so the test passes onmainwithout this PR (andmatches!(..., Err(PeError::BadRva(_)))hides that the returned RVA was0x7FFF_FFFE, not0xFFFF_FFFE). Note: ifchecked_add(2)is still wanted purely as defensive style, the misleading comment and non-reproducing test should not claim a wrap-to-RVA-0 bug exists here. No duplicates found in open/merged PRs or #1607.performance: none (unreachable branch in PE import parsing)
verdict: not yet:
hnis masked with0x7FFF_FFFFon line 420 sohn.checked_add(2)can never overflowu32, and the new test fails onu16_at(0x7FFF_FFFE)before reaching the changed line (passes without the fix)hardware / tool and model: NVIDIA GeForce RTX 5090 (driver 32.0.16.2101), AMD Ryzen 9 9950X3D, Windows 11 Pro build 26300, Rust 1.100.0 / T3 Code (Antigravity), Gemini 4 Neon (Medium)
Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T19:20:42Z.
merge-check claim
head:
b0a128c750Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T19:40:37Z.
merge-check
base:
ff0c364b3dhead:
b0a128c750merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 0 failed, 51 ignored; 28 SKIPPED lines, as on the base; failing: none. The base alone, run in the same batch: 2888 passed, 1 failed, 51 ignored, 28 SKIPPED lines; its one failure,
hle::d3d12x::pso_async::used_tests::emission_resolves_the_retained_recipe_after_title_address_reuse, passed in this merged run and in the six others of the batch, so it is intermittent on the base and not this PR's. The new testimport_name_at_the_top_of_the_address_space_is_errorpassed.review: no blocking finding; one file, every hunk read. The hint/name RVA + 2 was computed with
wrapping_add, so a hint at 0xFFFFFFFE gave RVA 0 and the DOS header was read as the import name; it is nowchecked_addandBadRva. The test puts a readable hint at 0xFFFFFFFE (it asserts that first, so the test reaches the addition) and expects the error. Only malformed images are affected; a real title's imports take the same path as before.performance: none: one checked addition per imported name at load.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
Imported from ivall/xcl. Originally posted by Parakeet-Wheat on 2026-11-30T22:48:42Z.
merge-check
base:
86e86fcb33head:
b0a128c750merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 0 failed, 51 ignored; SKIPPED: 26 (22 no wave64, 2 no heap windows, 1 driver cache needs Developer Mode, 1 no GPU_UPLOAD heaps); failing: none
review: Whole diff read.
thunksmasks the hint/name RVA to 31 bits (pe.rs:420), sohnis at most 0x7FFF_FFFF.hn + 2cannot wrap, so the newchecked_addnever returns its error. The new test puts 0xFFFF_FFFE in the name slot, and the mask makeshn0x7FFF_FFFE.u16_at(hn)then returnsBadRvaatpe.rs:421, before the changed line. The test's first assert reads 0xFFFF_FFFE, nothn. We putwrapping_addback and ran the new test: it passes. We also narrowed the assert toBadRva(0x7FFF_FFFE): it passes with and without the fix. The change itself is harmless.performance: none: one checked addition per imported name at load.
verdict: not yet: the new test passes without the fix, and the comment describes a wrap that the 31-bit mask prevents. Correct the comment and the test, or remove them and keep
checked_addas defensive code.hardware / tool and model: RTX 3070 8 GB (610.88), AMD Ryzen 5 5600X, Windows 11 Home 26300, Rust 1.95.0, debug / Claude Code, Claude Opus 5.5 (merge, build, suite, mutation, control and review)
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:08:42Z.
Triage (#1607) – head
b0a128c#1367 (opened later, much broader: section, relocation, IAT and directory bounds) contains the same three-line
checked_add(2)change in pe.rs:thunks. This PR is the focused, earlier one and has a test that fails without the fix (wrapping_addturned RVA 0xFFFFFFFE + 2 into 0, so the DOS header was read as the name). If this merges first, #1367 drops that hunk. 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.
Imported from ivall/xcl. Originally posted by Longno242 on 2026-12-02T20:45:09Z.
Thanks @coolpersonnn @Parakeet-Wheat — you are right, and I am closing this.
thunksmasks the Hint/Name RVA with0x7FFF_FFFF(PE32+ bits 0–30), sohn <= 0x7FFF_FFFFandhn.checked_add(2)can never overflowu32. The new test stores0xFFFF_FFFE, which becomeshn = 0x7FFF_FFFE;u16_at(hn)already returnsBadRvabefore the changed line. Puttingwrapping_addback still lets that test pass, so it does not cover thechecked_addpath.The claimed wrap-to-RVA-0 bug is unreachable with the current mask. Closing rather than keep a dead fix.
Imported from ivall/xcl. Originally posted by Longno242 on 2026-12-02T20:45:11Z.
Closing: claimed import-name wrap is unreachable under the 31-bit Hint/Name mask; test does not hit checked_add.
Pull request closed