VFS: fix MergedFind UAF and add null pointer checks (#1388) #1652
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1662"
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 hajduzsolt on 2026-11-24T18:53:55Z.
Fix a use-after-free and null-pointer dereference in the VFS
MergedFinditerator, and add null-pointer guards in
find_first_vfs,hk_find_next_w,and
hk_find_next_a(#1388).What is in it
MERGED: Mutex<Option<HashSet<usize>>>+ rawBox::into_raw/Box::from_rawpointer round-trips withMERGED: Mutex<Option<HashMap<usize, MergedFind>>>keyed by opaque odd synthetic handles; the lock is held across the lookup + increment so the iterator cannot alias or dangle.find_first_vfs,hk_find_next_w, andhk_find_next_aagainst nulllpFindFileDataby returningERROR_INVALID_PARAMETER(87) early.merged_find_null_data_and_close_are_safethat fails without the fix.Tested
rustc 1.98.1 (48a229cea 2026-09-01), debug (cargo test).cargo test -p xcl --lib vfs_hooks::tests -- --test-threads=2: 11 passed; 0 failed; 0 ignored.cargo test --workspace -- --test-threads=2: 778 passed; 0 failed; 41 ignored.Regression run
main:
PR:
Not tested
FindFirstFile/FindNextFilecalls from multiple threads.AI use
Imported from ivall/xcl. Originally posted by MiharaxD on 2026-11-24T19:27:17Z.
Test report on an NVIDIA card, head
d3a962f(onmainc160d86), which covers the "NVIDIA" line.Tested
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4(debug) ond3a962f: 859 passed, 0 failed, 42 ignored (lib tests 810 / 0 / 22).merged_find_null_data_and_close_are_safepasses.gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).Regression run
scripts/smoke.ps1 -Game <game folder> -Seconds 60(release builds, start screen, no input).mainisc160d86:main:
this PR's head:
Not tested
FindFirstFile/FindNextFilefrom several threads at once; the smoke is a regression check only.AI use: Claude Code (Claude Opus 5.5) built the PR, ran the tests and both smoke runs, read the logs and wrote this report; I checked it before posting.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T21:26:28Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored.Thanks!
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-25T20:15:51Z.
NVIDIA test report for
d3a962f(head as is, basec160d86), for #1607's "one more test report" list. RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11, debug, aftercargo build --workspace:cargo test --workspace --no-fail-fast -- --test-threads=4 --skip hle::xaudio2: 850 passed, 0 failed, 42 ignored. The end-to-end title tests pass.hle::xaudio2, because its tests fail or hang on this machine onmaintoo. The PR doesn't touch it.no wave64on this card, 1 no heap windows.AI-assisted (Claude Code, Claude Opus 5.5). Synthetic tests only; no title run.
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T11:18:31Z.
Independent desktop NVIDIA verification of PR #1662 at head
d3a962fa8aa89c01a26e0644b2582c261a575ec7(1commit; exact parent & merge-base:c160d86ef2efe3a07e4dfb473e4fa72eafb413c0, pre-#2555ancestor ofmain).Environment
7956 MiBreported by D3D12, Wave32-only Ada), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted tests & build (
d3a962fa)cargo test --release -p xcl --lib merged_find_null_data_and_close_are_safe -- --nocapture(3 consecutive runs)1 passed; 0 failed; 0 ignored; 831 filtered out× 3 (0.00s,0.00s,0.00s,0skipped)cargo test --release -p xcl --lib vfs_hooks:: -- --nocapture(3 consecutive runs)11 passed; 0 failed; 0 ignored; 821 filtered out× 3 (0.01s,0.01s,0.01s,0skipped)cargo build --release -p xcl1m 20s, exit0,0new warnings invfs_hooks.rs)Paired quiet 60 s retail smoke (
title: 29640639)(Note:
scripts/smoke.ps1atc160d86epredates9683e7a6and printed the local folder basename ontitle:; replaced below with the standard9683e7a6title hash29640639, with all measured fields verbatim.)Exact parent & merge-base (
c160d86ef2efe3a07e4dfb473e4fa72eafb413c0):PR #1662 (
d3a962fa8aa89c01a26e0644b2582c261a575ec7):Limits of coverage
merged_find_null_data_and_close_are_safeand all11/11vfs_hooks::unit tests (0skipped) passed3/3on Windows 11 NTFS, directly covering the#1388MergedFindhandle-table lifetime fix and null-pointer guards.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).
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:26:07Z.
Triage (#1607) – head
d3a962f#1415 fixes the same use-after-free in vfs_hooks.rs. In both PRs, hk_find_next_w/_a now read the MergedFind entry while holding the MERGED lock, and hk_find_close frees it under that same lock. #1415 does it with the boxed handle, this PR with a HashMap that owns the entries and synthetic handles. The observable change is the same.
#1415 was opened first, merges cleanly, and has a test that races FindNext against FindClose on 8 threads. This PR conflicts with main, and its test (
merged_find_null_data_and_close_are_safe) never runs FindNext and FindClose at the same time, so it does not exercise the race.The null
data/outchecks (error 87) are a separate change. If they are still wanted after #1415, they can go in a PR of their own.Recommendation: close (duplicate of #1415).
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 throny on 2026-12-02T10:18:56Z.
Closing as a duplicate of #1415: #1607 group D224, checked by Foniass and Decodere, who both read the diffs and suggest keeping #1415. If something here is not in #1415, say so and reopen it, or ask and I will.
AI use: Claude Code (Claude Opus 5.5) ran the closing script.
Pull request closed