Fix #2412: reject out-of-range export addresses in parse_exports #3165
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3165
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3165"
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?
@tharun-37 on GitHub · 2026-11-26 10:46 UTC · original
tharun-37:fix/texture-untracked-refresh→main· +162 −24 · 5 files · 5 commits · closed without mergingFix #2412: Export address validation now uses checked_sub() instead of wrapping_sub(), preventing integer overflow when an export address is below image_base or exceeds u32::MAX.
The previous code used wrapping_sub() which silently wraps/truncates out-of-range addresses into bogus 32-bit RVAs instead of returning an error.
Changes:
Added test rejects_export_address_below_image_base verifying that an export address below image_base is rejected.
@AurumCarlos on GitHub · 2026-11-26 13:13 UTC · original · reviewed
Thanks for picking up #2412. The diff carries a lot more than the description says, though: five files, of which only the
parse_exportshunk is about export addresses. I'd suggest splitting it, because some of the other changes would be hard to accept as part of this PR.1. The
parse_exportschange is fine, but defensive only.objectbuildsReadTarget::Addressasimage_base + rvawith a 32-bit RVA, soaddress - image_baseis always in0..=u32::MAXandwrapping_subwas already exact.checked_sub+try_fromis a reasonable guard against a future change there. It just can't be reached today, which the description should say rather than describing a live overflow.2. The new test doesn't test a rejection.
rejects_export_address_below_image_baseunwrapsImageInfo::parseand expects analphaexport. That only passes because nothing is rejected: the0x1200in the address table is an RVA thatobjectaddsimage_baseto, so the address isimage_base + 0x1200, not "< image_base" as the comment says. (parse_exportserrors propagate throughparsewith?, so a real rejection would make theunwrappanic.) As written, it's a test of the valid path under a misleading name.3.
rva_to_file_offsetchanges behaviour, and it isn't mentioned. Onmain,backed = vs.min(file_size): raw padding past the virtual size is not part of the section in memory (the comment you removed said so). Now anydelta < file_sizereturns a file offset, so an RVA past a section's virtual end, but inside its raw padding, maps into that padding. Withfind_mapover sections, that can return the wrong bytes for an RVA that belongs to the next section. The new tail,(delta < backed).then_some(None)?, evaluates toNoneon both branches, so the "mapped as zeros" case is the same as not matching. I'd drop this hunk from the PR.4. Two GPU tests are weakened.
descriptor/host.rs:NumDescriptors >= HEAP_VIEWS(2²¹) becomes>= 4.memory.rs:pairs >= 1 << 18("past the dynamic slots") becomespairs < caps, which checks something different while keeping the old message.If these fail on your machine because of a capped descriptor heap, that's a real host limitation, and other PRs are handling it on its own (e.g. #3191). Loosening the assertions here would hide regressions on normal hosts.
5. Two GPU fixes deserve their own PRs.
shadow.rs/copy_back_marks: the deadlock you describe looks real. Inpage_of, whenk >= pages(..), the upgradedArc<Shadow>is dropped inside the closure whilemarks()is held, andShadow::droptakesmarks()again. Collecting the strong refs under the lock and filtering after is the right shape. It's worth a separate PR with its own description and, ideally, a test.texture.rs: re-uploading subresources in untracked pages is a behaviour change to texture refresh, also unrelated to exports. Its test also says "Reserve a 4 KiB window" whileWINDOWis2 * PAGE= 128 KiB, and it never exercises a refresh, onlyuntracked()/take()/clean().So my suggestion: keep this PR to the
parse_exportshunk (with a test that really feeds an out-of-range address, or a note that it's defensive), and send theshadow.rsandtexture.rschanges separately. Drop therva_to_file_offsetand test-assertion changes.@tharun-37 on GitHub · 2026-11-26 16:03 UTC · original
Closing to split into separate PRs - this PR had unrelated changes mixed in. Will create a clean PR with just the #2412 fix.
Pull request closed