HLE XG: reject null output buffer when *count > 0 in GetResourceTiling #3072
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!3072
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3072"
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?
@Dukestar69 on GitHub · 2026-11-26 06:26 UTC · original
Dukestar69:fix/xg-tiling-null-out→main· +78 −3 · 1 files · 2 commits · closed without mergingSummary
Guards against a null-pointer dereference in
XGTextureAddressComputer::GetResourceTiling(tiling, vtable slot0x50) when a caller passes a non-nullcountwith*count > 0and a nulloutbuffer, returningE_INVALIDARGbefore writing any output parameters.Why
In
crates/victory-hle/src/modules/xg.rs,tilingchecked every other optional output pointer (tiles,packed,shape,count) via.as_mut(), but never checkedout: *mut SubresourceTilingfor null. On any 64 KiB tiled texture with at least one standard mip, passing*count > 0without == nullexecutedout.add(i as usize).write(entry)through a null pointer (access violation / UB). Passing*count == 0without == nullremains accepted (S_OK, writing 0 entries).Verification
modules::xg::tests::tiling_rejects_null_out_when_count_nonzeroverifying:*count > 0without == nullreturnsE_INVALIDARGwithout mutatingtilesorcount.*count == 0without == nullreturnsS_OKand still fillstiles.cargo test -p victory-hle xg::tests: 5 passed, 0 failed.cargo clippy -p victory-hle --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@kotekompotek on GitHub · 2026-11-26 06:32 UTC · original · approved these changes
Verified: *count>0 + null out -> E_INVALIDARG before any output write (tiles/count untouched, asserted); *count==0 + null out stays valid and returns S_OK with 0 entries. Matches XG semantics.
@fuzeofficlal on GitHub · 2026-11-26 08:03 UTC · original · requested changes
Tested locally on Windows 11 x64 (
rustc 1.98.1):cargo clippy -p victory-hle --all-targets --locked -- -D warnings: clean.cargo test -p victory-hle --locked: 153 lib + 1 fidelityfx + 1 no_dll_planting passed, 0 failed.One aliasing edge case remains in
tiling(crates/victory-hle/src/modules/xg.rs:487-537):*countto decide whetherout.is_null()is allowed, thenif let Some(t) = tiles.as_mut()writes*t = (l.size / TILE) as u32(e.g.2for the existing BC7 fixture), and finally the loop re-reads*countto computewanted = (standard * slices).saturating_sub(first).min(*n).tilesandcountto the same initially zerou32while passingout == null, the entry check sees0and passes, writing*tilesmutates*countto a nonzero tile count, and the loop then writes through a nullout.Reading the input capacity from
*countonce into a local variable before writing any output parameters—and using that saved capacity for both the null-outcheck andwanted—closes this cleanly. Please also add a unit test covering the aliasedtiles == countzero-capacity case.@Dukestar69 on GitHub · 2026-11-26 08:19 UTC · original
Good catch @fuzeofficlal, thanks! Fixed in
0d546b2:capacityfrom*countonce up front before writing any output pointers, and use that savedcapacityfor both the null-outguard andwanted.tiles == countzero-capacity with nulloutregression check totiling_rejects_null_out_when_count_nonzero.cargo test -p victory-hle --locked(153 lib + 2 integration passed),cargo clippy -p victory-hle --all-targets --locked -- -D warnings(clean), andcargo xtask policy(191 files ok).Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@Marvisak on GitHub · 2026-11-26 08:23 UTC · original
Automated triage for the maintainers.
Verdict: proposed close. The new check in
tiling(modules/xg.rs, slot 0x50) guards against a caller passing room for*count > 0entries with a nullout. That breaks the method's own contract, and there's no sign the title does it. The module states its stance at the top: "Title code passes pointers the real library would trust", andtiling's SAFETY comment saysouthas room for*countentries.The PR also picks
E_INVALIDARGas the console library's answer with no evidence of what the library returns. A guard for an impossible case with an invented return value isn't something the repo takes.What would change this: evidence that the title (or another real caller) makes this call, and of what the console library returns for it.
CI: not run on this head.
This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the
triage: proposed closelabel.Generated by Claude Code
@Dukestar69 on GitHub · 2026-11-26 09:31 UTC · original
Closing per triage feedback:
modules/xg.rsintentionally trusts caller contracts and there is no evidence of a title passing*count > 0without == null. Thanks for the review! Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).Pull request closed