feat(net): store DNS servers set through sceNetSetDnsInfo and sceNetSetDns6Info #9506

Merged
Noxy-HNR merged 2 commits from upstream-pr/9506 into main 2026-10-25 20:13:38 +00:00
Noxy-HNR commented 2026-10-21 23:46:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Noxy-HNR on 2026-10-21T23:46:25Z.


What

Converts sceNetSetDnsInfo, sceNetSetDns6Info and sceNetGetDns6Info from NotImplemented_nid_no_patch:

  • sceNetSetDnsInfo and sceNetSetDns6Info copy the info through the checked guest read (GuestSockets::ReadGuest) and store the given DNS servers; an unreadable info answers EFAULT, a null info clears them, and a zero primary server or nonzero flags answer EINVAL.
  • sceNetGetDnsInfo reports the stored IPv4 servers once some are set and the host's servers otherwise.
  • sceNetGetDns6Info reports the stored IPv6 servers, or none, and returns the server count; a null info or nonzero flags answer EINVAL on both getters, as measured on firmware 13.42 (BunnyFl's check in this thread). Every DNS call answers ENOTINIT before sceNetInit.

The resolver keeps using the host's servers: the stored servers are only reported back by the two getters, and docs/dev/debt/libSceNet.md records that gap. The argument checks and counts follow shadPS4's net.cpp; they are not measured on a console and are recorded in docs/dev/debt/libSceNet.md. libSceNet goes from 64/223 to 67/223 in tools/progress.py.

Tested

Windows 11 26H2 (build 10.0.26300, WinLibs GCC 15.2.0 r7, full Release build), head e2dd1a1 rebased onto main 9b1ed88: guest_net_dns_info (IPv4 and IPv6 set, get, clear and argument checks, EFAULT with the stored servers kept for an unreadable non-null info, and sceNetGetDns6Info throwing for nonzero flags and a null info) and guest_sce_net (including its IPv6 socket checks) pass, 2/2. tools/check_conventions.py --base origin/main and tools/check_test_registration.py pass. tools/pr_overlap.py reports no shared lines or exports with other open pull requests; it lists only shared files it could not compare because those pull requests conflict with main. An earlier Linux run (Ubuntu 24.04, GCC 13.3, Release) of 13d0c80 on main ab347d1 passed guest_net_dns_info and guest_sce_net's sceNetGetDnsInfo checks. No title tested.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4959876626 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9506). Originally posted by [Noxy-HNR](https://github.com/Noxy-HNR) on 2026-10-21T23:46:25Z. --- ### What Converts `sceNetSetDnsInfo`, `sceNetSetDns6Info` and `sceNetGetDns6Info` from `NotImplemented_nid_no_patch`: - `sceNetSetDnsInfo` and `sceNetSetDns6Info` copy the info through the checked guest read (`GuestSockets::ReadGuest`) and store the given DNS servers; an unreadable info answers `EFAULT`, a null info clears them, and a zero primary server or nonzero flags answer `EINVAL`. - `sceNetGetDnsInfo` reports the stored IPv4 servers once some are set and the host's servers otherwise. - `sceNetGetDns6Info` reports the stored IPv6 servers, or none, and returns the server count; a null info or nonzero flags answer `EINVAL` on both getters, as measured on firmware 13.42 (BunnyFl's check in this thread). Every DNS call answers `ENOTINIT` before `sceNetInit`. The resolver keeps using the host's servers: the stored servers are only reported back by the two getters, and `docs/dev/debt/libSceNet.md` records that gap. The argument checks and counts follow [shadPS4's net.cpp](https://github.com/shadps4-emu/shadPS4/blob/0918faa0255e9816b795b62c9b09eaea51a1bc5e/src/core/libraries/net/net.cpp); they are not measured on a console and are recorded in `docs/dev/debt/libSceNet.md`. libSceNet goes from 64/223 to 67/223 in `tools/progress.py`. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 26H2 (build 10.0.26300, WinLibs GCC 15.2.0 r7, full Release build), head e2dd1a1 rebased onto main 9b1ed88: `guest_net_dns_info` (IPv4 and IPv6 set, get, clear and argument checks, `EFAULT` with the stored servers kept for an unreadable non-null info, and `sceNetGetDns6Info` throwing for nonzero flags and a null info) and `guest_sce_net` (including its IPv6 socket checks) pass, 2/2. `tools/check_conventions.py --base origin/main` and `tools/check_test_registration.py` pass. `tools/pr_overlap.py` reports no shared lines or exports with other open pull requests; it lists only shared files it could not compare because those pull requests conflict with `main`. An earlier Linux run (Ubuntu 24.04, GCC 13.3, Release) of 13d0c80 on main ab347d1 passed `guest_net_dns_info` and `guest_sce_net`'s `sceNetGetDnsInfo` checks. No title tested. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-10-22 00:50:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T00:50:22Z.

Review: CHANGES_REQUESTED


The repo's overlap rule says that when the overlap report identifies open PRs changing the same lines or exports, authors must agree which lands first and the PR must declare that order with Depends on.

I checked the current open libSceNet PRs against this branch. Pairwise merge attempts report content conflicts in Export.cpp and/or docs/dev/debt/libSceNet.md with #5836, #8204, #8225, #8232, #8234, #8235, #8254 and #8362. The DNS test registration also shares the libSceNet CMake insertion area changed by #5836/#8254 and the test reorganization in #6044. Several of the function changes are conceptually separate, but the overlap rule still requires coordinating their landing order and recording any prerequisite in the checklist.

Please contact the affected authors to agree on the order, update Depends on to list the agreed prerequisites (or none if they confirm this PR can land first), and rerun the overlap/conventions checks after updating. I’m requesting changes only for this missing coordination record; the current eligibility, conventions, intake, labels and report checks pass. Linux, Windows, relinker and sanitizer product jobs are skipped for this PR, so they provide no hosted build result here. The PR reports the Ubuntu DNS test and conventions/test-registration checks; I have not rerun a local build.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5607984666 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9506#pullrequestreview-5607984666). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T00:50:22Z. **Review:** CHANGES_REQUESTED --- The repo's overlap rule says that when the overlap report identifies open PRs changing the same lines or exports, authors must agree which lands first and the PR must declare that order with `Depends on`. I checked the current open libSceNet PRs against this branch. Pairwise merge attempts report content conflicts in `Export.cpp` and/or `docs/dev/debt/libSceNet.md` with #5836, #8204, #8225, #8232, #8234, #8235, #8254 and #8362. The DNS test registration also shares the libSceNet CMake insertion area changed by #5836/#8254 and the test reorganization in #6044. Several of the function changes are conceptually separate, but the overlap rule still requires coordinating their landing order and recording any prerequisite in the checklist. Please contact the affected authors to agree on the order, update `Depends on` to list the agreed prerequisites (or `none` if they confirm this PR can land first), and rerun the overlap/conventions checks after updating. I’m requesting changes only for this missing coordination record; the current eligibility, conventions, intake, labels and report checks pass. Linux, Windows, relinker and sanitizer product jobs are skipped for this PR, so they provide no hosted build result here. The PR reports the Ubuntu DNS test and conventions/test-registration checks; I have not rerun a local build.
MarcZX10 commented 2026-10-22 02:06:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T02:06:57Z.

Review: CHANGES_REQUESTED


The DNS state behavior is localized and the author accurately records that console semantics are unverified, but there is a guest-pointer safety gap in the new setters. sceNetSetDnsInfo dereferences info->primaryAddress and later copies *info; sceNetSetDns6Info reads info->primaryAddress and copies *info directly. These are guest pointers, so an invalid non-null address can fault the host process instead of returning a guest error. The new tests cover null and value checks, but not unreadable non-null inputs. Please copy/probe these structures through the project’s guest-memory-safe mechanism before reading them, preserve the existing error behavior on invalid pointers, and add a regression for an unreadable non-null pointer. I did not run local tests. Separately, the required coordination/order for overlapping libSceNet export/debt/CMake/test edits is still unresolved; please record agreed predecessors or author-confirmed none before merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608456699 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9506#pullrequestreview-5608456699). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T02:06:57Z. **Review:** CHANGES_REQUESTED --- The DNS state behavior is localized and the author accurately records that console semantics are unverified, but there is a guest-pointer safety gap in the new setters. `sceNetSetDnsInfo` dereferences `info->primaryAddress` and later copies `*info`; `sceNetSetDns6Info` reads `info->primaryAddress` and copies `*info` directly. These are guest pointers, so an invalid non-null address can fault the host process instead of returning a guest error. The new tests cover null and value checks, but not unreadable non-null inputs. Please copy/probe these structures through the project’s guest-memory-safe mechanism before reading them, preserve the existing error behavior on invalid pointers, and add a regression for an unreadable non-null pointer. I did not run local tests. Separately, the required coordination/order for overlapping libSceNet export/debt/CMake/test edits is still unresolved; please record agreed predecessors or author-confirmed `none` before merge.
MarcZX10 commented 2026-10-22 02:07:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T02:07:11Z.


I reviewed the three new DNS functions and found a guest-pointer safety concern: both setters read fields through info and copy *info directly after only checking null. Please validate/copy from guest memory safely and cover an unreadable non-null input in the regression test. I also checked the current overlap report: #5836, #6044, #6879, #7201, #8204, #8225, #8232, #8234, #8235, #8254, and #8362 touch shared files (some are broad/base-conflicted warnings). I asked the relevant authors to identify exact overlaps and confirm ordering; please update Depends on/the overlap note based on those replies rather than leave the blanket none until that check is resolved.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330953942 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9506#issuecomment-6330953942). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T02:07:11Z. --- I reviewed the three new DNS functions and found a guest-pointer safety concern: both setters read fields through `info` and copy `*info` directly after only checking null. Please validate/copy from guest memory safely and cover an unreadable non-null input in the regression test. I also checked the current overlap report: #5836, #6044, #6879, #7201, #8204, #8225, #8232, #8234, #8235, #8254, and #8362 touch shared files (some are broad/base-conflicted warnings). I asked the relevant authors to identify exact overlaps and confirm ordering; please update `Depends on`/the overlap note based on those replies rather than leave the blanket `none` until that check is resolved.
MarcZX10 commented 2026-10-22 04:22:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:22:24Z.

Review: DISMISSED


Correction to my earlier pointer-safety finding: the current head copies both non-null input structures through GuestSockets::ReadGuest before inspecting them, and GuestNetDnsInfo.cpp now includes unreadable-page regression cases. That resolves the host-fault concern; I withdraw it.

Two items remain before merge:

  1. The current overlap report lists shared libSceNet CMake, export and debt paths with multiple open PRs, including #9523, #9525, #9542, #9543 and #9544. The checklist still says Depends on: none, and there is no author coordination recorded. Please compare the exact hunks, agree landing order with affected authors wherever ordering is required, declare prerequisites, and refresh the overlap check.
  2. This branch and its reported Linux test are based on main 6ef5a1c4, while current upstream main is c61d20f54801efc3798555829f6fedcff71ad7ff. Please update the branch and rerun the focused DNS/pointer test, conventions and overlap checks on current main.

The current hosted eligibility, conventions, labels and report checks pass; product/relinker jobs are skipped. I did not rerun local tests. No remaining pointer-safety defect is claimed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609232102 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9506#pullrequestreview-5609232102). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T04:22:24Z. **Review:** DISMISSED --- Correction to my earlier pointer-safety finding: the current head copies both non-null input structures through `GuestSockets::ReadGuest` before inspecting them, and `GuestNetDnsInfo.cpp` now includes unreadable-page regression cases. That resolves the host-fault concern; I withdraw it. Two items remain before merge: 1. The current overlap report lists shared libSceNet CMake, export and debt paths with multiple open PRs, including #9523, #9525, #9542, #9543 and #9544. The checklist still says `Depends on: none`, and there is no author coordination recorded. Please compare the exact hunks, agree landing order with affected authors wherever ordering is required, declare prerequisites, and refresh the overlap check. 2. This branch and its reported Linux test are based on main `6ef5a1c4`, while current upstream main is `c61d20f54801efc3798555829f6fedcff71ad7ff`. Please update the branch and rerun the focused DNS/pointer test, conventions and overlap checks on current main. The current hosted eligibility, conventions, labels and report checks pass; product/relinker jobs are skipped. I did not rerun local tests. No remaining pointer-safety defect is claimed.
Noxy-HNR commented 2026-10-22 04:52:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Noxy-HNR on 2026-10-22T04:52:34Z.


Overlap check for reviewers, on head 13d0c80 and current main (17f5335):

I merge-tested this branch against the 53 open PRs that touch the libSceNet Export.cpp, CMakeLists.txt or debt file, SocketRuntime.hpp or Udp.cpp in libkernel, or the new test. 41 of them merge cleanly with both main and this branch, including #9523, #9525, #9542, #9543 and #9544. The other 12 already conflict with main. For 9 of those the conflicts are identical with and without this branch. #8234, #8235 and #8362 are on older bases, and their existing conflicts gain a few adjacent lines (the sceNetGetDnsInfo debt entry, and for #8362 the sceNetSetDns6Info body next to its old stub). None of the three changes DNS code, and each needs a rebase onto main regardless.

No other open PR implements or changes sceNetSetDnsInfo, sceNetSetDns6Info, sceNetGetDns6Info or sceNetGetDnsInfo. #8463 also edits the static ReadGuest in Udp.cpp that GuestSockets::ReadGuest forwards to. Merged with this branch, the file has one definition and a matching declaration, so neither PR breaks the other. tools/pr_overlap.py lists only shared files it could not compare because those PRs conflict with main. Depends on stays none.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6333019188 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9506#issuecomment-6333019188). Originally posted by [Noxy-HNR](https://github.com/Noxy-HNR) on 2026-10-22T04:52:34Z. --- Overlap check for reviewers, on head 13d0c80 and current `main` (17f5335): I merge-tested this branch against the 53 open PRs that touch the libSceNet `Export.cpp`, `CMakeLists.txt` or debt file, `SocketRuntime.hpp` or `Udp.cpp` in libkernel, or the new test. 41 of them merge cleanly with both `main` and this branch, including #9523, #9525, #9542, #9543 and #9544. The other 12 already conflict with `main`. For 9 of those the conflicts are identical with and without this branch. #8234, #8235 and #8362 are on older bases, and their existing conflicts gain a few adjacent lines (the `sceNetGetDnsInfo` debt entry, and for #8362 the `sceNetSetDns6Info` body next to its old stub). None of the three changes DNS code, and each needs a rebase onto `main` regardless. No other open PR implements or changes `sceNetSetDnsInfo`, `sceNetSetDns6Info`, `sceNetGetDns6Info` or `sceNetGetDnsInfo`. #8463 also edits the static `ReadGuest` in `Udp.cpp` that `GuestSockets::ReadGuest` forwards to. Merged with this branch, the file has one definition and a matching declaration, so neither PR breaks the other. `tools/pr_overlap.py` lists only shared files it could not compare because those PRs conflict with `main`. Depends on stays none.
harisibrar1 commented 2026-10-22 13:24:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-22T13:24:55Z.

Review: COMMENTED


Checked against main 830ccd121f and shadPS4 net.cpp at 0918faa0255e9816b795b62c9b09eaea51a1bc5e (L1343-1400):

  • The struct layouts match main's NetDnsInfo/NetDns6Info (Export.cpp:199-213). The set/get round trip, clear-on-null and counts match the pinned shadPS4 code, and the single g_dnsLock covers every access. Thanks for the careful port.
  • Rules question on the setters: the stored servers are only read back by the two getters (g_dnsOverride/g_dns6Override at Export.cpp:2393 and :2621). Every lookup still goes through host ::getaddrinfo/::getnameinfo (main Export.cpp:2051-2058, :2162). So sceNetSetDnsInfo({8.8.8.8, 0}, 0) returns success, but sceNetResolverStartNtoa keeps querying the host's servers. CONTRIBUTING.md only allows a success that doesn't do the work as a silent stub that unblocks a title and only affects the UI, listed under "Silent stubs". Here Unblocks is none and the debt entry sits under "Functional". Would you consider keeping the two setters on NotImplemented_nid_no_patch until a title needs them (or until the resolver uses the stored servers), or else moving the entry to Silent stubs with the title it unblocks?
  • Small consistency point: main's sceNetGetDnsInfo throws for nonzero flags and for a null info because the console results are unknown (Export.cpp:2370-2371). The new sceNetGetDns6Info returns NET_EINVAL for the same unmeasured inputs, taken from shadPS4. It might be worth handling both getters the same way, either both throwing or both following shadPS4 with the source cited in the debt entry.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5614928244 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9506#pullrequestreview-5614928244). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-22T13:24:55Z. **Review:** COMMENTED --- Checked against main 830ccd121f and shadPS4 net.cpp at 0918faa0255e9816b795b62c9b09eaea51a1bc5e (L1343-1400): - The struct layouts match main's `NetDnsInfo`/`NetDns6Info` (Export.cpp:199-213). The set/get round trip, clear-on-null and counts match the pinned shadPS4 code, and the single `g_dnsLock` covers every access. Thanks for the careful port. - Rules question on the setters: the stored servers are only read back by the two getters (`g_dnsOverride`/`g_dns6Override` at Export.cpp:2393 and :2621). Every lookup still goes through host `::getaddrinfo`/`::getnameinfo` (main Export.cpp:2051-2058, :2162). So `sceNetSetDnsInfo({8.8.8.8, 0}, 0)` returns success, but `sceNetResolverStartNtoa` keeps querying the host's servers. CONTRIBUTING.md only allows a success that doesn't do the work as a silent stub that unblocks a title and only affects the UI, listed under "Silent stubs". Here `Unblocks` is none and the debt entry sits under "Functional". Would you consider keeping the two setters on `NotImplemented_nid_no_patch` until a title needs them (or until the resolver uses the stored servers), or else moving the entry to Silent stubs with the title it unblocks? - Small consistency point: main's `sceNetGetDnsInfo` throws for nonzero flags and for a null info because the console results are unknown (Export.cpp:2370-2371). The new `sceNetGetDns6Info` returns `NET_EINVAL` for the same unmeasured inputs, taken from shadPS4. It might be worth handling both getters the same way, either both throwing or both following shadPS4 with the source cited in the debt entry. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
boykopovar/AnyPS5!9506
No description provided.