HLE: return Winsock sockaddr errors from getnameinfo on invalid input #2995

Closed
github-bot wants to merge 1 commit from github-bot/gh-2995 into main AGit
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 02:47 UTC · original
fuzeofficlal:fix/hle-net-getnameinfo-malformed-addr → main · +154 −13 · 1 files · 1 commits · closed without merging

Problem

name_info_flags in crates/victory-hle/src/modules/net.rs relied on socket_addr(sa, len) returning Option<SocketAddr>. When a caller passed a null sockaddr, a negative/short sa_len (< 2), a truncated AF_INET (< 16) or AF_INET6 (< 28) address, or an unsupported address family, socket_addr returned None, causing reverse_resolvable(None) to emit a spurious "network reverse lookup blocked" log and return WSAHOST_NOT_FOUND (11001) under NI_NAMEREQD.

Native Windows ws2_32.dll (getnameinfo / GetNameInfoW) instead sets and returns WSAEFAULT (10014) for null/undersized sockaddr inputs and WSAEAFNOSUPPORT (10047) for unsupported address families.

Fix

  • Add name_info_addr to parse sockaddr for getnameinfo / GetNameInfoW, returning Err(WSAEFAULT) for null or undersized buffers and Err(WSAEAFNOSUPPORT) for unsupported families.
  • Have name_info_flags return Result<i32, i32>, setting WSASetLastError(err) and returning err on invalid inputs before applying the offline reverse-lookup policy for valid IPv4/IPv6 addresses.
  • Forward the returned error directly from both getnameinfo and GetNameInfoW.

Verification

  • Added modules::net::tests::getnameinfo_reports_winsock_address_errors_instead_of_host_not_found covering both getnameinfo and GetNameInfoW across null sockaddr (NI_NAMEREQD & NI_NUMERICHOST), negative length, short header (len = 1), truncated AF_INET / AF_INET6, unsupported family (99), and valid non-loopback IPv4 (203.0.113.1 with and without NI_NAMEREQD), asserting both return values and WSAGetLastError().
  • cargo test --locked -p victory-hle -- --test-threads=1: 153/153 unit + 2/2 integration tests passed.
  • cargo clippy --locked -p victory-hle --tests -- -D warnings (default & --all-features): 0 warnings.
  • cargo xtask policy: 191 files ok.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 02:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/2995) `fuzeofficlal:fix/hle-net-getnameinfo-malformed-addr` → `main` · +154 −13 · 1 files · 1 commits · closed without merging ## Problem `name_info_flags` in `crates/victory-hle/src/modules/net.rs` relied on `socket_addr(sa, len)` returning `Option<SocketAddr>`. When a caller passed a null `sockaddr`, a negative/short `sa_len` (`< 2`), a truncated `AF_INET` (`< 16`) or `AF_INET6` (`< 28`) address, or an unsupported address family, `socket_addr` returned `None`, causing `reverse_resolvable(None)` to emit a spurious `"network reverse lookup blocked"` log and return `WSAHOST_NOT_FOUND` (`11001`) under `NI_NAMEREQD`. Native Windows `ws2_32.dll` (`getnameinfo` / `GetNameInfoW`) instead sets and returns `WSAEFAULT` (`10014`) for null/undersized `sockaddr` inputs and `WSAEAFNOSUPPORT` (`10047`) for unsupported address families. ## Fix - Add `name_info_addr` to parse `sockaddr` for `getnameinfo` / `GetNameInfoW`, returning `Err(WSAEFAULT)` for null or undersized buffers and `Err(WSAEAFNOSUPPORT)` for unsupported families. - Have `name_info_flags` return `Result<i32, i32>`, setting `WSASetLastError(err)` and returning `err` on invalid inputs before applying the offline reverse-lookup policy for valid IPv4/IPv6 addresses. - Forward the returned error directly from both `getnameinfo` and `GetNameInfoW`. ## Verification - Added `modules::net::tests::getnameinfo_reports_winsock_address_errors_instead_of_host_not_found` covering both `getnameinfo` and `GetNameInfoW` across null `sockaddr` (`NI_NAMEREQD` & `NI_NUMERICHOST`), negative length, short header (`len = 1`), truncated `AF_INET` / `AF_INET6`, unsupported family (`99`), and valid non-loopback IPv4 (`203.0.113.1` with and without `NI_NAMEREQD`), asserting both return values and `WSAGetLastError()`. - `cargo test --locked -p victory-hle -- --test-threads=1`: **153/153 unit + 2/2 integration tests passed**. - `cargo clippy --locked -p victory-hle --tests -- -D warnings` (default & `--all-features`): 0 warnings. - `cargo xtask policy`: 191 files ok.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:19:40 +00:00
github-bot 2026-11-26 06:31:26 +00:00
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 04:49 UTC · original

Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head 306a4b7 (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: getnameinfo_reports_winsock_address_errors_instead_of_host_not_found.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-26 04:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2995#issuecomment-7182929755) Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head `306a4b7` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **867 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `getnameinfo_reports_winsock_address_errors_instead_of_host_not_found`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 05:41 UTC · original

Automated triage for the maintainers.

Needs work. name_info_flags (crates/victory-hle/src/modules/net.rs) now parses the sockaddr itself (name_info_addr). For a null, short or unknown-family address it returns WSAEFAULT/WSAEAFNOSUPPORT without calling the host's getnameinfo/GetNameInfoW. The offline guard is not loosened. Valid non-loopback addresses still get NI_NUMERICHOST or WSAHOST_NOT_FOUND, and invalid ones no longer reach the host at all.

What this actually changes is narrow. On main, an invalid address without NI_NAMEREQD already went to the host with NI_NUMERICHOST added, and the host returned the same WSAEFAULT/WSAEAFNOSUPPORT. The only different result is invalid input with NI_NAMEREQD, which now gets the address error instead of WSAHOST_NOT_FOUND. Both are failures, and nothing shows the title passing a malformed sockaddr to these calls. To make this worth merging, please show that the title reaches this case: a log from a title run, or the call site in the title's code. Without that, it is a guard for input the title does not send, and it would be proposed for closing.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 05:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2995#issuecomment-7183716844) <!-- victory-triage v1 head=306a4b7657a32cc2d7fdb61f498ad969620462f2 verdict=needs-work at=2026-11-26T05:41:17Z --> Automated triage for the maintainers. **Needs work.** `name_info_flags` (`crates/victory-hle/src/modules/net.rs`) now parses the `sockaddr` itself (`name_info_addr`). For a null, short or unknown-family address it returns `WSAEFAULT`/`WSAEAFNOSUPPORT` without calling the host's `getnameinfo`/`GetNameInfoW`. The offline guard is not loosened. Valid non-loopback addresses still get `NI_NUMERICHOST` or `WSAHOST_NOT_FOUND`, and invalid ones no longer reach the host at all. What this actually changes is narrow. On `main`, an invalid address without `NI_NAMEREQD` already went to the host with `NI_NUMERICHOST` added, and the host returned the same `WSAEFAULT`/`WSAEAFNOSUPPORT`. The only different result is invalid input with `NI_NAMEREQD`, which now gets the address error instead of `WSAHOST_NOT_FOUND`. Both are failures, and nothing shows the title passing a malformed `sockaddr` to these calls. To make this worth merging, please show that the title reaches this case: a log from a title run, or the call site in the title's code. Without that, it is a guard for input the title does not send, and it would be proposed for closing. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 06:09 UTC · original

Fair point from triage — without NI_NAMEREQD, main already returns the host's WSAEFAULT/WSAEAFNOSUPPORT, and I have no title-run evidence showing malformed sockaddr inputs with NI_NAMEREQD. Closing to keep the queue focused on higher-impact changes; happy to reopen if a title log ever hits this path.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 06:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/2995#issuecomment-7184141431) Fair point from triage — without `NI_NAMEREQD`, `main` already returns the host's `WSAEFAULT`/`WSAEAFNOSUPPORT`, and I have no title-run evidence showing malformed `sockaddr` inputs with `NI_NAMEREQD`. Closing to keep the queue focused on higher-impact changes; happy to reopen if a title log ever hits this path.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2995
No description provided.