fix(libkernel): connect libSceNet sockets #18474

Merged
THEMANnt merged 1 commit from upstream-pr/18474 into main 2026-11-12 19:36:50 +00:00
THEMANnt commented 2026-11-11 17:37:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-11-11T17:37:26Z.


What

Route POSIX connect for a libSceNet descriptor through the socket owner, preserving its connection bookkeeping and the kernel entry point's address validation.

Tested

Windows x64, GCC 15.2. Built and passed guest_sce_net_kernel_forwards on this branch. Connect a bound UDP socket to a loopback peer through libkernel and check that a null address returns EFAULT. #17253 changes native address validation, and #18167 touches nearby regression code.

All six socket bridge changes also passed the combined Windows socket and public header checks. Repository conventions passed for this branch. No retail title was run.

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:5264033034 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18474). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-11-11T17:37:26Z. --- ### What Route POSIX `connect` for a `libSceNet` descriptor through the socket owner, preserving its connection bookkeeping and the kernel entry point's address validation. ### 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 x64, GCC 15.2. Built and passed `guest_sce_net_kernel_forwards` on this branch. Connect a bound UDP socket to a loopback peer through `libkernel` and check that a null address returns `EFAULT`. #17253 changes native address validation, and #18167 touches nearby regression code. All six socket bridge changes also passed the combined Windows socket and public header checks. Repository conventions passed for this branch. No retail title was run. ### 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-11-12 14:27:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T14:27:15Z.

Review: COMMENTED


Reviewed — no blocking findings

Read the diff of all four changed files and the head code it touches; I found no concrete defect, and nothing was built or run.

What I ran

Head SHA 45d177c61f240840d3f6d091fc752059e3aeb164, base main. Read-only review through the repository reader, no build and no test run.

Reader calls
python3 repo_read.py search "connect_nid_postfix|bool Failed|Failed\(" core/libs/prx/libSceNet core/libs/tests/GuestNetKernelForwards.cpp core/libs/tests/GuestTest.hpp
python3 repo_read.py search "ForwardsFor" core/libs
python3 repo_read.py search "sceNetConnect" core/libs
python3 repo_read.py search "Forwards" core/libs
python3 repo_read.py cat core/libs/prx/libSceNet/Export.cpp 1495 1545
python3 repo_read.py cat core/libs/prx/libSceNet/Export.cpp 1088 1100
python3 repo_read.py cat core/libs/prx/libkernel/Socket/src/Udp.cpp 285 312
python3 repo_read.py cat core/libs/prx/libkernel/Socket/src/Udp.cpp 1668 1700
python3 repo_read.py cat core/libs/prx/libkernel/Socket/src/Udp.cpp 1822 1830
python3 repo_read.py cat core/libs/tests/GuestNetKernelForwards.cpp 1 40
python3 repo_read.py cat core/libs/tests/GuestNetKernelForwards.cpp 52 80

Results

Check Result Note
Diff of the four changed files passed Read in full as hunks
Forwards field order and the new lambda passed connect sits between bind and getsockname in both
Recursion through sceNetConnect passed libSceNet does not call connect_nid_postfix
Null address returns EFAULT (14) passed Read only: AddressLengthError returns 14 before forwarding
Build and test guest_sce_net_kernel_forwards not run No build in this run
Windows socket and header checks not run Author-reported only
Negative control

Not run. I made no change to the code under test.

Findings

Blocking

None.

Non-blocking

  • core/libs/tests/GuestNetKernelForwards.cpp:78 adds a connect and checks only its return value. A later send without an address, or a recv from another peer being dropped, would show the connection took effect. The test does not check either. Non-blocking, because the path itself reads correctly.

Sources

Not verified

  • Build and run of guest_sce_net_kernel_forwards, on Linux or Windows. The Windows run in the description is the author's report, not mine.
  • The description's claim that the connection bookkeeping is preserved. The bookkeeping sits in sceNetConnect after line 1545, and I did not read that part.
  • Wrong-length handling for a forwarded connect. bind checks the length per family before forwarding (Udp.cpp:1825-1828); the connect path does not, so the check falls to sceNetConnect and guest_to_native_address. I did not read that function.
  • The related PRs #17253 and #18167 named in the description, and the claim that no other open PR implements the same functions.
  • Full text of the four changed files was not read; I read the hunks and their callers only.

To get this to a good state

No change is required for this review. Before merge, the author's own run of guest_sce_net_kernel_forwards on the head 45d177c61f240840d3f6d091fc752059e3aeb164 should be rerun on Linux as well as Windows, and the reader's sceNetConnect tail (after line 1545) should be checked for the bookkeeping the description claims.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5876116232 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18474#pullrequestreview-5876116232). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-12T14:27:15Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Read the diff of all four changed files and the head code it touches; I found no concrete defect, and nothing was built or run. ## What I ran Head SHA `45d177c61f240840d3f6d091fc752059e3aeb164`, base `main`. Read-only review through the repository reader, no build and no test run. <details> <summary>Reader calls</summary> ``` python3 repo_read.py search "connect_nid_postfix|bool Failed|Failed\(" core/libs/prx/libSceNet core/libs/tests/GuestNetKernelForwards.cpp core/libs/tests/GuestTest.hpp python3 repo_read.py search "ForwardsFor" core/libs python3 repo_read.py search "sceNetConnect" core/libs python3 repo_read.py search "Forwards" core/libs python3 repo_read.py cat core/libs/prx/libSceNet/Export.cpp 1495 1545 python3 repo_read.py cat core/libs/prx/libSceNet/Export.cpp 1088 1100 python3 repo_read.py cat core/libs/prx/libkernel/Socket/src/Udp.cpp 285 312 python3 repo_read.py cat core/libs/prx/libkernel/Socket/src/Udp.cpp 1668 1700 python3 repo_read.py cat core/libs/prx/libkernel/Socket/src/Udp.cpp 1822 1830 python3 repo_read.py cat core/libs/tests/GuestNetKernelForwards.cpp 1 40 python3 repo_read.py cat core/libs/tests/GuestNetKernelForwards.cpp 52 80 ``` </details> ## Results | Check | Result | Note | |---|---|---| | Diff of the four changed files | passed | Read in full as hunks | | `Forwards` field order and the new lambda | passed | `connect` sits between `bind` and `getsockname` in both | | Recursion through `sceNetConnect` | passed | libSceNet does not call `connect_nid_postfix` | | Null address returns EFAULT (14) | passed | Read only: `AddressLengthError` returns 14 before forwarding | | Build and test `guest_sce_net_kernel_forwards` | not run | No build in this run | | Windows socket and header checks | not run | Author-reported only | <details> <summary>Negative control</summary> Not run. I made no change to the code under test. </details> ## Findings ### Blocking None. ### Non-blocking - `core/libs/tests/GuestNetKernelForwards.cpp:78` adds a connect and checks only its return value. A later send without an address, or a recv from another peer being dropped, would show the connection took effect. The test does not check either. Non-blocking, because the path itself reads correctly. ## Sources - Forwarded connect path: https://github.com/boykopovar/AnyPS5/blob/45d177c61f240840d3f6d091fc752059e3aeb164/core/libs/prx/libkernel/Socket/src/Udp.cpp#L1670-L1675 - Address length check before forwarding: https://github.com/boykopovar/AnyPS5/blob/45d177c61f240840d3f6d091fc752059e3aeb164/core/libs/prx/libkernel/Socket/src/Udp.cpp#L303-L307 - Export lambda: https://github.com/boykopovar/AnyPS5/blob/45d177c61f240840d3f6d091fc752059e3aeb164/core/libs/prx/libSceNet/Export.cpp#L1116-L1124 - `sceNetConnect` body: https://github.com/boykopovar/AnyPS5/blob/45d177c61f240840d3f6d091fc752059e3aeb164/core/libs/prx/libSceNet/Export.cpp#L1495-L1545 ## Not verified - Build and run of `guest_sce_net_kernel_forwards`, on Linux or Windows. The Windows run in the description is the author's report, not mine. - The description's claim that the connection bookkeeping is preserved. The bookkeeping sits in `sceNetConnect` after line 1545, and I did not read that part. - Wrong-length handling for a forwarded connect. `bind` checks the length per family before forwarding (`Udp.cpp:1825-1828`); the connect path does not, so the check falls to `sceNetConnect` and `guest_to_native_address`. I did not read that function. - The related PRs #17253 and #18167 named in the description, and the claim that no other open PR implements the same functions. - Full text of the four changed files was not read; I read the hunks and their callers only. ## To get this to a good state No change is required for this review. Before merge, the author's own run of `guest_sce_net_kernel_forwards` on the head `45d177c61f240840d3f6d091fc752059e3aeb164` should be rerun on Linux as well as Windows, and the reader's `sceNetConnect` tail (after line 1545) should be checked for the bookkeeping the description claims.
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!18474
No description provided.