Skip to content

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

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
Noxy-HNR:claude/project-thread-420hnm
Oct 25, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
Noxy-HNR:claude/project-thread-420hnm

Conversation

@Noxy-HNR

@Noxy-HNR Noxy-HNR commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Progress report (7a25f87 → 44393a3)

📈 System libraries: 49.95% (+0.03%, +3 implemented functions)

✅ 3 implemented
Library Name
libSceNet sceNetGetDns6Info
libSceNet sceNetSetDns6Info
libSceNet sceNetSetDnsInfo

Changed libraries (implemented exports)

Library Before After Change
libSceNet 74/224 (33.04%) 77/224 (34.38%) +1.34 pp

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 5836 core/libs/prx/libSceNet/CMakeLists.txt
core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 7088 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7201 core/libs/prx/libSceNet/Export.cpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7475 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 8605 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 9509 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 9932 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 9948 core/libs/prx/libSceNet/Export.cpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 10502 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 10621 core/libs/prx/libkernel/Socket/src/Udp.cpp

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

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 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Noxy-HNR force-pushed the claude/project-thread-420hnm branch from bed7b5c to 13d0c80 Compare October 22, 2026 04:31
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 22, 2026
@Noxy-HNR

Noxy-HNR commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

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.

@Noxy-HNR
Noxy-HNR marked this pull request as ready for review October 22, 2026 05:08

@harisibrar1 harisibrar1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked against main 830ccd1 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.

@Noxy-HNR
Noxy-HNR force-pushed the claude/project-thread-420hnm branch from 13d0c80 to e2dd1a1 Compare October 22, 2026 18:30
@Noxy-HNR

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review, @harisibrar1.

Getters: agreed. sceNetGetDns6Info now throws for nonzero flags and a null info, the same as sceNetGetDnsInfo, because the console results for those inputs are unknown. The test checks both throws.

Setters: storing the guest's servers and reporting them back through the getters is the behaviour this PR models. The part it doesn't reproduce, the resolver using those servers, is a gap, and the debt entry now states that gap first: the resolver keeps using the host's DNS servers, and the setters only store the guest's servers for the getters to report back. A title that sets servers and reads them back gets consistent answers, while lookups still go through the host resolver. I didn't list them under Silent stubs because the stored values are observable and tested, not a bare success. If a maintainer would rather keep both setters on NotImplemented_nid_no_patch until the resolver honours them, I'll make that change.

Rebased onto main 9b1ed88. guest_net_dns_info and guest_sce_net pass, 2/2, on Windows 11 with GCC 15.2.0. Conventions and overlap are rerun, and Tested is updated.

@BunnyFl

BunnyFl commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Firmware check of the argument checks, which follow shadPS4 here: libSceNet.sprx from firmware 13.42, each case run in an emulator on the module.

  • sceNetSetDnsInfo(info, flags): non-zero flags give 0x80410116 (errno 22) first; a null info clears the stored servers and returns 0; a primary server of 0 gives 0x80410116; otherwise it stores the 8 bytes. sceNetSetDns6Info does the same with a 16-byte primary address and stores 32 bytes. This matches the PR's setters.
  • sceNetGetDnsInfo and sceNetGetDns6Info give 0x80410116 for a null info or non-zero flags, before they read the system's DNS servers. The PR throws for both cases in both getters, as main does for sceNetGetDnsInfo, because the console results were unknown. On 13.42 they are EINVAL.
  • All four return 0x804101C8 with errno 200 while the library isn't initialised.
  • The setters read info directly: 13.42 has no EFAULT result for an unreadable non-null info, so that answer and its test are AnyPS5's own guest-memory safety, not console behaviour.

Noxy-HNR added a commit to Noxy-HNR/AnyPS5 that referenced this pull request Oct 25, 2026
Apply the firmware 13.42 module-probe report in PR boykopovar#9506: all four DNS calls check initialization first; getters return EINVAL for null outputs or nonzero flags; setters reject flags before reading guest memory. Keep the checked input copy and document EFAULT as host safety, not firmware behavior. Use the current public Net.hpp declarations in the regression.

Rebased onto upstream e7e3e9c. Ubuntu 24.04, GCC 13.3, Release: actual libc/libkernel/libSceNet libraries and both focused test executables built. guest_sce_net passes. A separate harness linked against those unmodified libraries passes initialization, errno, invalid flags, unreadable-input flag precedence, null clearing and unchanged-output checks. The full guest_net_dns_info test is blocked here: process_vm_readv is denied with EPERM by the execution environment. No full DNS regression pass is claimed. Public-header audit, conventions, test registration and whitespace checks pass.

The resolver still uses host DNS; IPv6 host-server discovery and firmware server-count behavior remain debt. Firmware evidence: boykopovar#9506 (comment)

AI-assisted: yes
@Noxy-HNR
Noxy-HNR force-pushed the claude/project-thread-420hnm branch from e2dd1a1 to 9e469c2 Compare October 25, 2026 04:29
@adriadam10 adriadam10 self-assigned this Oct 25, 2026
@adriadam10
adriadam10 dismissed MarcZX10’s stale review October 25, 2026 15:15

Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.

Noxy-HNR and others added 2 commits October 25, 2026 18:56
Apply the firmware 13.42 module-probe report in PR boykopovar#9506: all four DNS calls check initialization first; getters return EINVAL for null outputs or nonzero flags; setters reject flags before reading guest memory. Keep the checked input copy and document EFAULT as host safety, not firmware behavior. Use the current public Net.hpp declarations in the regression.

Rebased onto upstream e7e3e9c. Ubuntu 24.04, GCC 13.3, Release: actual libc/libkernel/libSceNet libraries and both focused test executables built. guest_sce_net passes. A separate harness linked against those unmodified libraries passes initialization, errno, invalid flags, unreadable-input flag precedence, null clearing and unchanged-output checks. The full guest_net_dns_info test is blocked here: process_vm_readv is denied with EPERM by the execution environment. No full DNS regression pass is claimed. Public-header audit, conventions, test registration and whitespace checks pass.

The resolver still uses host DNS; IPv6 host-server discovery and firmware server-count behavior remain debt. Firmware evidence: boykopovar#9506 (comment)

AI-assisted: yes
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@adriadam10
adriadam10 force-pushed the claude/project-thread-420hnm branch from 9e469c2 to 44393a3 Compare October 25, 2026 18:00
@adriadam10
adriadam10 merged commit 74ac0e7 into boykopovar:main Oct 25, 2026
10 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the setters' guest read (EFAULT test on an unreadable page), ENOTINIT/EINVAL/clear-on-null against shadPS4 and the firmware 13.42 probe above, the server counts, and the debt entry stating that the resolver still uses the host's servers. The full Build failed patched_libraries because libSceNet referenced the C++ symbol GuestSockets::ReadGuest, which libkernel does not export across libraries; I added a GuestSocketReadGuest_nid_no_patch export (same pattern as GuestSocketIsOpen_nid_no_patch) and rebased onto main; merged.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants