Skip to content

XCL_NETWORK=0: WSAConnectByList refuses all but loopback - #821

Open
mastrr9 wants to merge 1 commit into
xcl-dev:mainfrom
mastrr9:fix/netoff-wsaconnectbylist
Open

mastrr9 wants to merge 1 commit into
xcl-dev:mainfrom
mastrr9:fix/netoff-wsaconnectbylist

Conversation

@mastrr9

@mastrr9 mastrr9 commented Nov 24, 2026

Copy link
Copy Markdown

Draft pending scripts/smoke.ps1 regression blocks on a retail title (welcome from anyone with a title, or will be added once available).

With XCL_NETWORK=0, WSAConnectByList was hooked neither in the title's import table nor in ws2_32.dll, and connects without passing through the hooked connect or WSAConnect. On Windows 11 with install_system_hooks() active, calling WSAConnectByList with 192.0.2.1:80 bypassed every hook and attempted a live TCP connect until WSAETIMEDOUT (10060) after 21.04 s. (WSAConnectByNameW and WSAConnectByNameA are already blocked because they call the hooked GetAddrInfoExW internally and fail in microseconds with WSAHOST_NOT_FOUND.)

What is in it

Tested

  • Environment: NVIDIA GeForce RTX 5080 (16 GB, wave32, driver 617.42 / 32.0.16.1742), Windows 11 Pro 25H2 (26200.9974), D3D12 debug layer installed (d3d12SDKLayers.dll), rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC from Windows SDK 10.0.26100.0, debug build.
  • Negative control (unmodified main d208e14): empirical Windows 11 probe with install_system_hooks() confirmed WSAConnectByList(192.0.2.1:80) bypassed all hooks and timed out with WSAETIMEDOUT (10060) after 21.04 s.
  • Command (at head fdabe7392327c5472ddad9cbfccbbdb07a135f69): cargo build --workspace && cargo test --workspace -- --test-threads=4
  • Result: 714 passed, 0 failed, 41 ignored (0 new warnings).
    • hle::netoff::tests::wsa_connect_by_list_refuses_all_but_loopback — ok
  • SKIPPED (2): gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64).

Not tested

  • scripts/smoke.ps1 regression runs on a retail title (hence draft), AMD/wave64 hardware, and release build.

AI use

  • Claude Opus 5.5 (via Claude Duet / Claude Code) flagged the WSAConnectByList lead and wrote the hook implementation and unit test.
  • Antigravity (Gemini 4 Neon & Gemini 4 Hydrogen) empirically confirmed the Windows 11 bypass (and verified WSAConnectByNameW/A were already blocked), audited the x64 SOCKET_ADDRESS_LIST layout, ran the full Windows RTX 5080 MSVC + D3D12 debug-layer workspace suite, and drafted this PR description.

@SlopTart

Copy link
Copy Markdown

2|
3|AMD/wave64 + release-build datapoint, plus a Wine caveat: the new unit test cannot run under Wine at all.
4|
5|Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Wine = Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust 1.100.0 cross x86_64-pc-windows-gnu, release profile, XCL_NETWORK=0, native wave64. Same rig as my Linux rows in #42 / #718.
6|
7|Merged state: head fdabe7392 onto main beaa245, clean merge.
8|
9|Full suite, cargo test --workspace --release --no-fail-fast -- --test-threads=4: 703 passed, 11 failed, 41 ignored (17 suites). 10 of the 11 are known: this rig's 7 stable Wine-lane failures (my #42 row) + the #718 flaky trio (~2/5 rate at threads=4, PR-independent). The 11th is yours:
10|
11|- hle::netoff::tests::wsa_connect_by_list_refuses_all_but_loopback fails under Wine: it panics at netoff.rs:403 on .expect("export") — GetProcAddress(ws2_32.dll, "WSAConnectByList") returns NULL under Proton Experimental (wine-11.0). Wine's ws2_32 does not export WSAConnectByList, so the test's system-address lookup dies before any assertion. Your sibling test the_systems_own_network_functions_refuse passes here, so the netoff lane itself is fine; it is specifically the WSAConnectByList binding. If the function genuinely does not exist in Wine, a Wine-visible skip (#[cfg]-style or a runtime GetProcAddress-NULL skip) would keep the suite green on Linux/Wine lanes like mine — but if titles running under Wine call it through some other path, worth checking what that means for the hook.
12|
13|Your the_systems_own_network_functions_refuse unit test passes here.
14|
15|Not tested: retail titles / scripts/smoke.ps1 (none here), Windows, MSVC.
16|Counts only, no game data.
17|AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

@mastrr9
mastrr9 force-pushed the fix/netoff-wsaconnectbylist branch from fdabe73 to 28fd53d Compare November 24, 2026 06:59
@mastrr9

mastrr9 commented Nov 24, 2026

Copy link
Copy Markdown
Author

Thanks for the Wine/Proton catch! Squashed a fix into 28fd53d829a5c4d9dd0b43b952c7f4493a57c146:

  • When GetProcAddress(ws2_32.dll, "WSAConnectByList") returns None (Wine/Proton), the test still verifies that our wsa_connect_by_list detour refuses non-loopback with WSAENETUNREACH and returns cleanly instead of panicking on .expect("export").
  • On native Windows where WSAConnectByList is exported, both the title import and system detour continue to be exercised in full.

Re-tested on native Windows 11 + NVIDIA RTX 5080 (28fd53d829a5c4d9dd0b43b952c7f4493a57c146, driver 617.42, rustc 1.100.0): cargo build --workspace clean, cargo test --workspace -- --test-threads=4: 714 passed, 0 failed, 41 ignored (SKIPPED: only the 2 no wave64 tests).

(Assisted-by: Antigravity / Gemini 4 Neon + Claude Sonnet 5.5)

@dcastell1

Copy link
Copy Markdown

Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on main@beaa245:

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
exit 0; 0 failed

XCL_NETWORK=0 and WSAConnectByList is green here and the workspace keeps its verdict (737 passed on main on this box). Tree restored afterwards; hardware adapter, no Wine, no game data.

AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

WSAConnectByList connects to the first address of a list that answers
without going through the hooked connect, and it was hooked neither in
the title's imports nor in the system's ws2_32. With XCL_NETWORK=0 it
made a live TCP connect (measured on Windows 11: to 192.0.2.1:80 until
WSAETIMEDOUT after 21 s). WSAConnectByNameW/A were already refused,
since they resolve through the hooked GetAddrInfoExW.

It now goes through the same check as connect: a list with no
loopback entry fails with WSAENETUNREACH; a list with only loopback
entries goes to the original as it is; a mixed list goes to the
original with a copy that holds only its loopback entries, in order.
The system hook is installed after the main table so the table and its
statics are left as they are.

Test: wsa_connect_by_list_refuses_all_but_loopback checks the loopback
filter on a mixed list, then calls both the title-side function and the
system export (through GetProcAddress, after install_system_hooks) with
an invalid socket: no loopback gives 10051, a mixed or loopback list
reaches Winsock and fails with its own error. Not built or run on
Windows.

Assisted-by: Claude Code (Claude Opus 5.5)
@OrangeCrane1738

OrangeCrane1738 commented Nov 24, 2026 •

Copy link
Copy Markdown

Test report for f9ef768 on the retail title: one 120 s smoke run without this PR and one with it.

Tested

Smoke runs

main 930e8b4 + #235

xcl-smoke v1
commit: fcc0a9ff026dedb611e32d3619fb374c67f87af0
gpu: NVIDIA GeForce RTX 5060 Ti
title: GTA6.Xbox.v1.0.2.1
seconds: 120
exit: 0x0
frames shown: 1140 (PresentX 1140)
presents per 2 s (last 3): 25 26 26
device removals: 0
crashes: 0
peak commit: 16514 MB

main 930e8b4 + #235 + #821 (f9ef768)

xcl-smoke v1
commit: 75c4d1b89050bef7936501cc23d263364de1106e
gpu: NVIDIA GeForce RTX 5060 Ti
title: GTA6.Xbox.v1.0.2.1
seconds: 120
exit: 0x0
frames shown: 1212 (PresentX 1212)
presents per 2 s (last 3): 24 24 24
device removals: 0
crashes: 0
peak commit: 15550 MB

Not tested

  • Runs of main and of this PR's head as they are (no Gaming Services here, see above).
  • A title that calls WSAConnectByList.
  • AMD; the cargo test suite (not run for this report).

AI use

  • Claude Opus 5.5 (in the Claude app): set up the test script, read the logs and wrote this report. The runs were made on my own machine with my own copy; nothing from the game is attached.

@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run of f9ef7685 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: f9ef76857b281b1502c7b9b21f093c72d26e4426
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1613 (PresentX 1613)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14814 MB

Against the limits in CONTRIBUTING.md: 100 % 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants