XCL_NETWORK=0: the system's WSASendMsg refuses too #607
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/612"
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 Kalmarv on 2026-11-24T02:31:33Z.
With
XCL_NETWORK=0the system'ssendtoandWSASendToare hooked (db1ddb2, #305), butWSASendMsgis not, and it carries its destination in the message. On main508a0c7a datagram sent with it to an address the hookedsendtorefuses still arrives. This hooks it withsendto's rule: no address or loopback goes to the original, anything else is refused withWSAENETUNREACH.Follow-up to #305 (closed), found with the scratch test from #444.
What is in it
crates/xcl/src/hle/netoff.rs:ws2_32!WSASendMsgin the table ofinstall_system_hooks, its detourwsa_send_msgand the call to the original.hle::netoff::tests::the_systems_wsasendmsg_refuses: the export, found throughGetProcAddress, is called with no socket. For 8.8.8.8 the hook answers 10051 before it looks at the socket. For 127.0.0.1 the call reaches the system, which answers something else. No socket is opened and nothing is sent.Tested
cargo test --workspace -- --test-threads=4onbbf3174(this PR, on main508a0c7): 681 passed, 0 failed, 41 ignored (thexcllibrary: 641 passed, 21 ignored). SKIPPED GPU tests: 2, bothno wave64(gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware).508a0c7with only the test added: fails (left: 10093, right: 10051, the system's own answer);::ffff:127.0.0.1, which the hooks treat as any other host.508a0c7with the hooks:sendtoandWSASendToare refused (10051);WSASendMsgreturns 0 and the datagram arrives.WSASendMsgto 127.0.0.1 itself still arrives.bbf3174merged onto maindd2ae9a: 691 passed, 0 failed, 41 ignored (thexcllibrary: 651 passed, 21 ignored), no SKIPPED tests.Regression run
Our own runs, one after the other on the machine under Tested (RTX 5070 Ti), release builds, no uncommitted changes.
main:
PR:
Not tested
WSASendMsgthatWSAIoctl(SIO_GET_EXTENSION_FUNCTION_POINTER, WSAID_WSASENDMSG)hands out. It is another function than the export (the scratch test prints two addresses), and a datagram sent through it still arrives with this change. Refusing it needs a hook onWSAIoctl, which #462 (open) adds forConnectEx; it is not in this PR.WSASendMsgthrough the hook: the calls above are synchronous.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by MesshM on 2026-11-24T03:12:00Z.
Test run of
bbf31746947d2cbd98dd243f68eb42f96f48fdc6on AMD RDNA4. I merged it onto currentmaindd2ae9alocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 691 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 651 passed, 0 failed, 21 ignoredSKIPPED;the_systems_wsasendmsg_refusesandthe_systems_own_network_functions_refusepass.Review: On x64
WSAMSGstarts withname(8-byte pointer) andnamelen(INT at +8), which is whatwsa_send_msgreads; a null name (a connected socket) and loopback go to the original. A question rather than a finding: older code getsWSASendMsgthroughWSAIoctl(SIO_GET_EXTENSION_FUNCTION_POINTER)withWSAID_WSASENDMSGrather than the export. That pointer comes from the provider, so it would not go through this hook unless theWSAIoctlpath hands out the hooked function (asConnectExneeds too, see #444/#462). I did not check whether netoff already does that.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-24T03:13:28Z.
@MesshM, thanks for the RDNA4 run.
On the question: yes, that is a second path, and this PR does not cover it. I checked it on main
508a0c7and on this branch with a loopback-only scratch test:WSAIoctl(SIO_GET_EXTENSION_FUNCTION_POINTER, WSAID_WSASENDMSG)hands out is a different address from thews2_32export.sendtorefuses still arrives, with and without this change.Netoff has no hook on
WSAIoctlon main. #462 adds one forConnectEx; theWSASendMsgpointer can be answered in the same place once that is merged, and I will follow up then. It is under Not tested in the description.🤖 Claude Fable 5.2
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-24T12:49:24Z.
Windows / NVIDIA test of #612 (
bbf3174694) and #619 (2970626721) merged together ontomain47efa2e(both clean), with #570 rebased on top.Tested
cargo build --workspace && cargo test --workspace -- --test-threads=4on47efa2e+ #612 + #619 + #570: 743 passed, 0 failed, 41 ignored. SKIPPED:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64).cargo test -p xcl --lib netoff: 4 passed (only_loopback_goes_through,the_systems_own_network_functions_refuse,the_systems_wsasendmsg_refuses,a_bind_to_every_interface_stays_on_loopback).note_bindnext to the rewrittenloopbackdoc,O_BIND/O_WSA_SEND_MSG, the hooks array); resolved with both entries and the array at 20. I'll push that rebase to #570 once these two are in.Not tested: a retail run of this combined tree; AMD / Intel.
Run and written with Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T06:37:05Z.
Empirical test report (
bbf31746)Hardware / environment
bbf31746947d2cbd98dd243f68eb42f96f48fdc6(PR #612), clean detached checkout.10.0.26200.9974. CPU identified by Windows asAMD64 Family 23 Model 113 Stepping 0, AuthenticAMD, with 12 logical processors available to the process.1.100.0 (0ef1bc386 2026-11-09), hostx86_64-pc-windows-msvc. DXC1.9.2609.5 (01b62ad47).Invoke-ArcTest.ps1, with zero Arc GPU mutex hold.Commands and results
cargo test --workspace --no-runexited 0 and built 15 test executables. It emitted afetch_updatedeprecation warning. This command only compiled tests.XCL_ADAPTER=NONE_CPU_ONLYandRUST_TEST_NOCAPTURE=1,cargo test -p xcl --lib hle::netoff::tests::exited 0 with 3 passed, 0 failed, 0 ignored, and 0 skipped. The skip count is the number of case-sensitive log lines beginning withSKIPPED. The harness reported 659 tests filtered out.Observed behavior
WSASendMsgexport and verified that the hook refused the non-loopback destination withWSAENETUNREACH(10051). For127.0.0.1, the same invalid socket produced a different error. The test checks the error returned by the hook using an invalid socket.Not tested
The full GPU workspace suite and game smoke runs were omitted.
AI use
Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr612-focused.log and published.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T12:55:41Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by gut0to on 2026-11-26T16:37:21Z.
Review: COMMENTED
AI-assisted review (OpenAI GPT-6); I checked this path against the diff and Microsoft Winsock documentation. I did not run tests or the game.
Imported from ivall/xcl. Originally posted by gut0to on 2026-11-26T16:37:22Z.
Code review location:
crates/xcl/src/hle/netoff.rs; line 262Could a regression resolve and call the
WSASendMsgpointer returned byWSAIoctl(SIO_GET_EXTENSION_FUNCTION_POINTER, WSAID_WSASENDMSG)? The current test calls thews2_32export throughGetProcAddress, but Microsoft documents that the extension pointer can invoke the provider directly without passing throughWs2_32. That leaves a path for non-loopback traffic to bypass this export hook whileXCL_NETWORK=0. Please cover the returned pointer and ensure off-loopback sends remain refused. WSASendMsg, provider extension mechanism. AI-assisted review (OpenAI GPT-6); I checked this path against Microsoft documentation and did not run tests.Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-26T23:08:53Z.
@gut0to thanks. Confirmed by reading, not run: neither this PR (
bbf3174) nor main (8b957be) hooksWSAIoctl, so aWSASendMsgtaken fromSIO_GET_EXTENSION_FUNCTION_POINTER/WSAID_WSASENDMSGcalls the provider directly and skips this hook whileXCL_NETWORK=0.It is the same gap as #444:
ConnectExis only reachable through that pointer, and it still connects. Both are fixed in one place by hookingWSAIoctland handing back a refusing detour forWSAID_WSASENDMSGandWSAID_CONNECTEX, with a test that resolves each pointer and checks that an off-loopback call is refused. That fix belongs with #444, as its own PR. This PR stays thews2_32export, which it closes as described. I'll link the #444 PR here when it is up.AI use: Claude Code, Claude Opus 5.5 checked the code paths and wrote this reply.
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T03:01:18Z.
merge-check claim
head:
bbf3174694Imported from ivall/xcl. Originally posted by throny on 2026-11-28T03:16:03Z.
merge-check
base:
753e8b1ahead:
bbf3174694merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1513 passed, 0 failed, 47 ignored; its test uses an invalid socket, so nothing is sent (26 SKIPPED lines); base alone: 1512 passed, 0 failed, 47 ignored
review: it weakens no existing block and adds one. The message layout it reads is right for x64. What passes: a message without an address (a connected socket, which can only be loopback because connect is hooked) and the IPv4 and IPv6 loopback addresses; an IPv4-mapped loopback address is refused, which is the conservative side. Known gap, acknowledged by the author and not new: a WSASendMsg pointer obtained from the provider through WSAIoctl skips this hook (main does not hook that call; ConnectEx has the same gap), so XCL_NETWORK=0 is not complete with this PR either. If the hook cannot be installed, the existing warning fires and the process runs on unblocked, as for the other hooks. Minor: a non-null but invalid message pointer faults inside the hook instead of returning an error.
performance: none; network path only, and only with XCL_NETWORK=0.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T12:05:18Z.
merge-check claim
head:
bbf3174694Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T12:40:07Z.
merge-check
base:
e429936c10head:
bbf3174694merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2127 passed, 9 failed, 48 ignored, 25 SKIPPED: 21 no wave64, 3 per-lane f16/f32 forms refused (#1426 semantics), 1 no heap windows; failing: gpu::dxil::module::split::tests::dispatch_chain_oversized_loop_matches_whole, gpu::dxil::module::split::tests::dispatch_chain_wave32_live_loops, gpu::dxil::module::split::tests::dispatch_chain_wave64_live_loops_and_exchange, gpu::recomp::heap_window_tests::gpu_heap_flat_reads_match_guarded_and_root_output, gpu::recomp::tests::gpu_compute_mode_dispatch_abi, gpu::recomp::tests::gpu_float_cas_uses_ieee_equality, test_title_runs_and_game_folder_is_untouched, test_title_draws_with_a_root_signature_under_the_debug_layer, test_title_runs_under_the_debug_layer_with_dred: these 9 fail on the base too (the base e429936c's suite, run alone on this PC with the same command: 2126 passed, 9 failed, 48 ignored, 25 SKIPPED, these same 9 failing), and each also failed when rerun alone on this merge (the two debug-layer e2e tests stop on the D3D12 debug layer rejecting a pixel shader as corrupt or unsigned, and test_title_runs_and_game_folder_is_untouched on the test title's console command list memory-methods check, "post-Wait32/64 write failed"); not caused by this PR. The suite ran on this PC at the same time as 2 other PRs' suites, in one queued job.
review: none. Whole diff read (netoff.rs: WSASendMsg hooked like sendto: the destination is read from WSAMSG (name at +0, namelen at +8 on x64); no address or a loopback one goes to the original, any other is refused as unreachable; its own original pointer, no spare trampoline used; 1 test through the system's export, to another host and to loopback). Datagrams sent with WSASendMsg no longer bypass the offline mode.
performance: no runtime cost of note (one hook, on WSASendMsg calls only).
verdict: safe to merge
hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40, wave32 only), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc, debug test profile; trial merge 207e50beffbb072d474451e93bd234c0855f1270 (local, not pushed). Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).
correction (2026-11-28): the base counts above were first given as 2128 passed: that base run reused this PC's merge test binary (one cargo target dir for both sides). The base was rerun with its own target dir; the same 9 tests fail on it, so the classification and the verdict stand.