PE loader: refuse IAT and TLS-index writes that straddle SizeOfImage #1194
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1203"
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:11:44Z.
Stacked on #854; only the top commit belongs here.
#854 rejects IAT / delay-load HMODULE / TLS-index writes whose first byte is inside the headers or at/after
SizeOfImage. The loader still writes 8 bytes (IAT, HMODULE) or 4 bytes (TLS index), so a slot atSizeOfImage - 4could overwrite past the mapped image. Require the whole write to fit — the same bounds idea #291 applied to relocations.What is in it
crates/xcl/src/pe.rs:ensure_data_write_rva(rva, width)and tests for an IAT and TLS index that straddle the image endTested
c97bd9fc97bd9f98c2f136301658f5532709b5e313339f2(clean tree)cargo test --workspace -- --test-threads=4: 747 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)Regression run
scripts/smoke.ps1from @Toons29 (RX 9070, 60 s, same title/time; blocks as printed):Not tested
cargo test --workspacewidth=8path as IAT)AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T13:30:41Z.
Independent verification on current
main384f7f7(branch already contains it — clean).Machine: Windows 11, Ryzen 9 7900X; Rust stable MSVC, debug.
cargo test -p xcl --lib pe::: 16 passed, 0 failed — includes the newimport_address_table_in_headers_is_error,tls_index_in_headers_is_error,delay_import_module_handle_in_headers_is_error,import_address_table_straddling_image_end_is_error,tls_index_straddling_image_end_is_error,write_targets_at_size_of_headers_are_accepted— IAT/TLS-index writes straddlingSizeOfImageare refused as intended.AI use: test runs by Devin (Cognition, SWE-2); no code changes.
Imported from ivall/xcl. Originally posted by JoaoPauluu on 2026-11-24T14:35:02Z.
A run on Linux under Wine.
Tested
x86_64-pc-windows-gnu.c97bd9fas it is (based on47efa2e), no uncommitted changes. The lib test binary runs under Wine, one test per process (--exact).pe::tests::delay_import_module_handle_in_headers_is_error: ok, no SKIPPED.pe::tests::import_address_table_in_headers_is_error: ok, no SKIPPED.pe::tests::import_address_table_straddling_image_end_is_error: ok, no SKIPPED.pe::tests::tls_index_in_headers_is_error: ok, no SKIPPED.pe::tests::tls_index_straddling_image_end_is_error: ok, no SKIPPED.pe::tests::write_targets_at_size_of_headers_are_accepted: ok, no SKIPPED.Not tested
AI use
upstream-sync referenced this pull request2026-11-24 19:06:45 +00:00
Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:15:00Z.
Regression run of
c97bd9f9on 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:31Z.
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:43:48Z.
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-25T13:00:41Z.
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
c97bd9f.Result: cargo test --workspace -- --test-threads=4: 747 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:06Z.
Thanks @jennydeth — copied your workspace counts into Tested (747 passed, 0 failed, 41 ignored. SKIPPED: 2 GPU tests for no wave64 (expected on this card)).
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T07:43:24Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Longno242 on 2026-11-29T20:44:03Z.
Still waiting on a maintainer: description/smoke are in place; CI needs first-time-contributor workflow approval. Not abandoned.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:05:48Z.
Triage (#1607) – head
c97bd9fStacked on #854 (same author): the shared lines are #854's commits. This PR's own change makes
ensure_data_write_rvatake the write width and checks the end of the 8-byte IAT / HMODULE and 4-byte TLS-index writes against SizeOfImage, with tests for slots that straddle the image end. Neither is on main yet.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:47:13Z.
Rebased onto current
main(clean).cargo test -p xcl --lib pe::: 16 passed, 0 failed. Not abandoned — clearing stale.Pre-rebase retail smoke in the description is stale after the rebase; needs a fresh title-run pair on the new tip before merge.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T21:07:26Z.
Follow-up review of
903ae0fd, sincec97bd9f(code reading only, not a merge-check;Build and test (Windows, no GPU)red,PR descriptionred) · no new findingsIn short: The PR makes
ensure_data_write_rvatake the write width and checks the end of the 8-byte IAT /HMODULEand 4-byte TLS-index writes againstSizeOfImage, with tests for slots that straddle the image end. #854, which it was stacked on, has merged. This push only rebases ontomain, leaving this PR's single commit (git range-diffshows it is the same). Nothing blocks it.Checked and fine
mainthe stack is gone, so the diff is now only this PR's change.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
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.