fix(libkernel): accept connections on libSceNet sockets #18476

Merged
THEMANnt merged 2 commits from upstream-pr/18476 into main 2026-11-26 01:30:27 +00:00
THEMANnt commented 2026-11-11 17:37:33 +00:00 (Migrated from github.com)

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


What

Route POSIX accept for a libSceNet listener through the socket owner. Stage the complete peer address with a separate backend length, then limit the guest copy by the original caller capacity and the staging-buffer size. Close the accepted descriptor if guest copy-out fails.

The output length is the number of bytes copied, following FreeBSD 11.4 kern_accept4 and accept1. A four-byte IPv4 buffer therefore receives four bytes and reports length 4; the address's first byte still identifies the complete 16-byte sockaddr. The debt fragment records that this policy is FreeBSD-based and has not been measured on a PS5.

Tested

Windows 11 x64, WinLibs GCC 15.2.0, Ninja, Release, revision 7038be4e73.

  • Built and passed guest_sce_net_kernel_forwards, guest_kernel_web_forwards, guest_socket_connect_listening, and guest_kernel_socket_shutdown, each three consecutive times.
  • Expanded the accept matrix to 40 combinations: native and libSceNet-owned sockets, IPv4 and IPv6, and capacities 0, 1, 4, 15, 16, 17, 27, 28, 32, and UINT_MAX. Check the returned length, exact peer-address prefix, and untouched bytes after the permitted copy.
  • The original reviewed head cf6b8be4c7 also passes this expanded matrix. The follow-up makes capacity handling explicit while preserving its existing FreeBSD-compatible results.
  • Negative control: temporarily reporting/copying the backend's full address length instead of applying the caller-capacity limit makes guest_sce_net_kernel_forwards fail at the capacity assertion. Restoring the limit passes all four suites again.
  • git diff --check and repository conventions against the upstream merge base passed. The required comparison with the stale fork's origin/main includes upstream changes outside this PR.

No retail title, PS5 hardware, or new Linux/macOS runtime test was run locally. GitHub CI for this revision is separate from these local results.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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:5264034660 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18476). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-11-11T17:37:33Z. --- ### What Route POSIX `accept` for a `libSceNet` listener through the socket owner. Stage the complete peer address with a separate backend length, then limit the guest copy by the original caller capacity and the staging-buffer size. Close the accepted descriptor if guest copy-out fails. The output length is the number of bytes copied, following [FreeBSD 11.4 `kern_accept4` and `accept1`](https://github.com/freebsd/freebsd-src/blob/releng/11.4/sys/kern/uipc_syscalls.c#L278-L475). A four-byte IPv4 buffer therefore receives four bytes and reports length 4; the address's first byte still identifies the complete 16-byte sockaddr. The debt fragment records that this policy is FreeBSD-based and has not been measured on a PS5. ### Tested Windows 11 x64, WinLibs GCC 15.2.0, Ninja, Release, revision `7038be4e73`. - Built and passed `guest_sce_net_kernel_forwards`, `guest_kernel_web_forwards`, `guest_socket_connect_listening`, and `guest_kernel_socket_shutdown`, each three consecutive times. - Expanded the accept matrix to 40 combinations: native and libSceNet-owned sockets, IPv4 and IPv6, and capacities 0, 1, 4, 15, 16, 17, 27, 28, 32, and UINT_MAX. Check the returned length, exact peer-address prefix, and untouched bytes after the permitted copy. - The original reviewed head `cf6b8be4c7` also passes this expanded matrix. The follow-up makes capacity handling explicit while preserving its existing FreeBSD-compatible results. - Negative control: temporarily reporting/copying the backend's full address length instead of applying the caller-capacity limit makes `guest_sce_net_kernel_forwards` fail at the capacity assertion. Restoring the limit passes all four suites again. - `git diff --check` and repository conventions against the upstream merge base passed. The required comparison with the stale fork's `origin/main` includes upstream changes outside this PR. No retail title, PS5 hardware, or new Linux/macOS runtime test was run locally. GitHub CI for this revision is separate from these local results. <!-- 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. --> ### 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) and the licence notice of code adapted from upstream (see AGENTS.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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-11 17:57:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-11T17:57:32Z.

Review: CHANGES_REQUESTED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 7b84f85167:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • GitHub CI: failing check(s): pipe-write (macos-15), pipe-write (macos-15-intel).
  • Build: guest_net_kernel_forwards_tests built cleanly.
  • CTest (guest_sce_net_kernel_forwards):
    1/1 Test #3768: guest_sce_net_kernel_forwards ....   Passed    0.22 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNet/Export.cpp, core/libs/prx/libkernel/Socket/include/SocketPoll.hpp, core/libs/prx/libkernel/Socket/src/Udp.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #3768: guest_sce_net_kernel_forwards ....Subprocess aborted***Exception:   0.48 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • core/libs/prx/libkernel/Socket/src/Udp.cpp: Verified accept_nid_postfix pointer validation ordering, ensuring null/invalid length pointers return Fail(14) (EFAULT) via GuestCopyIn_nid_no_patch before forwarding to accept.
    • core/libs/prx/libkernel/Socket/src/Udp.cpp: Verified bounds safety on peer buffer staging (28 bytes, accommodating both sockaddr_in and sockaddr_in6) using std::minstd::uint32_t(capacity, sizeof(peer)) without narrowing conversions.
    • core/libs/prx/libkernel/Socket/src/Udp.cpp: Verified resource lifetime management ensuring that if guest copy-out fails on address or length, the accepted descriptor is cleanly closed via KernelCloseSocket_nid_no_patch before returning EFAULT.
    • core/libs/prx/libSceNet/Export.cpp & SocketPoll.hpp: Verified that the new accept forwarder lambda in g_socketForwards matches the struct Forwards function pointer signature and correctly maps sceNetAccept error codes via ErrorOf.
    • core/libs/tests/GuestNetKernelForwards.cpp: Verified that OpenStream tests both null and invalid pointer EFAULT error paths on forwarded sockets and validates loopback peer address retrieval and descriptor validity.
    • Repository rules (AGENTS.md): Verified zero comments in added code, Conventional Commits formatting, generic cross-platform LP64/LLP64 compatibility, and complete PR checklist metadata.
  • Note: the AI-assisted checkbox can stay.

Requesting changes for the points above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5863199664 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18476#pullrequestreview-5863199664). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-11T17:57:32Z. **Review:** CHANGES_REQUESTED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `7b84f85167`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **GitHub CI**: failing check(s): `pipe-write (macos-15)`, `pipe-write (macos-15-intel)`. - **Build**: `guest_net_kernel_forwards_tests` built cleanly. - **CTest** (`guest_sce_net_kernel_forwards`): ``` 1/1 Test #3768: guest_sce_net_kernel_forwards .... Passed 0.22 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNet/Export.cpp`, `core/libs/prx/libkernel/Socket/include/SocketPoll.hpp`, `core/libs/prx/libkernel/Socket/src/Udp.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #3768: guest_sce_net_kernel_forwards ....Subprocess aborted***Exception: 0.48 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - core/libs/prx/libkernel/Socket/src/Udp.cpp: Verified accept_nid_postfix pointer validation ordering, ensuring null/invalid length pointers return Fail(14) (EFAULT) via GuestCopyIn_nid_no_patch before forwarding to accept. - core/libs/prx/libkernel/Socket/src/Udp.cpp: Verified bounds safety on peer buffer staging (28 bytes, accommodating both sockaddr_in and sockaddr_in6) using std::min<std::uint32_t>(capacity, sizeof(peer)) without narrowing conversions. - core/libs/prx/libkernel/Socket/src/Udp.cpp: Verified resource lifetime management ensuring that if guest copy-out fails on address or length, the accepted descriptor is cleanly closed via KernelCloseSocket_nid_no_patch before returning EFAULT. - core/libs/prx/libSceNet/Export.cpp & SocketPoll.hpp: Verified that the new accept forwarder lambda in g_socketForwards matches the struct Forwards function pointer signature and correctly maps sceNetAccept error codes via ErrorOf. - core/libs/tests/GuestNetKernelForwards.cpp: Verified that OpenStream tests both null and invalid pointer EFAULT error paths on forwarded sockets and validates loopback peer address retrieval and descriptor validity. - Repository rules (AGENTS.md): Verified zero comments in added code, Conventional Commits formatting, generic cross-platform LP64/LLP64 compatibility, and complete PR checklist metadata. - Note: the AI-assisted checkbox can stay. Requesting changes for the points above.
MarcZX10 commented 2026-11-12 14:27:23 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Reviewed — no blocking findings

The diff routes accept on a libSceNet listener through the socket owner and stages the peer and length before the guest copy-out. In the changed hunks and the head context I read, I found no blocking defect.

What I ran

  • Head 7b84f85167feab995efa4382a60f086f52242226, base main. Static review only: no build and no tests were run.
  • Reader calls at head:
python3 <READER> search GuestCopyOut_nid_no_patch
python3 <READER> search sceNetAccept
python3 <READER> search "bool GuestCopyOut_nid_no_patch"
python3 <READER> cat core/libs/prx/libc/src/General.cpp 826 836
python3 <READER> cat core/libs/prx/libkernel/Socket/src/Udp.cpp 536 556
python3 <READER> cat core/libs/prx/libkernel/Socket/src/Udp.cpp 1700 1808
python3 <READER> cat core/libs/prx/libSceNet/Export.cpp 309 340
python3 <READER> cat core/libs/prx/libSceNet/Export.cpp 1373 1440
python3 <READER> search Forwards

Results

Check Result Note
Copy-out bound passed sceNetAccept clamps to the guest capacity
Positional Forwards init passed Only g_socketForwards initializes it
Copy-out failure passed Accepted descriptor is closed
Build and tests not run Author reports a Windows x64 run

Findings

Blocking

None.

Non-blocking

  1. core/libs/prx/libkernel/Socket/src/Udp.cpp:1746: the capacity clamp is not exercised. The test (core/libs/tests/GuestNetKernelForwards.cpp:138) always passes a 16-byte buffer for a 16-byte IPv4 peer, so no case covers a guest buffer shorter than the peer address.
  2. core/libs/tests/GuestNetKernelForwards.cpp:139: the peer and size checks run before Require(stream.accepted >= 0) at line 140. A failed accept would show up as a peer mismatch rather than as an accept error.

Not verified

  • The Windows x64 GCC 15.2 run of guest_sce_net_kernel_forwards, the combined socket and header checks, and the repository conventions check are author-reported. I did not run them.
  • The reference to #18166 is not checked.
  • The copy-out bound relies on sceNetAccept writing back the copied length, as read at core/libs/prx/libSceNet/Export.cpp:333-335. The path was not run on any platform.
  • Negative control: not run.
  • Files: all four changed files are in files/, but I did not read their full text. I read the diff hunks and the head ranges listed above. files.json was not read.

To get this to a good state

  • Author: optionally add a test where the guest buffer is shorter than the peer address, and move the accepted >= 0 check ahead of the size check. The Windows run listed above should be repeated on the new head if the code changes.

Sources

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5876118321 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18476#pullrequestreview-5876118321). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-12T14:27:23Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The diff routes `accept` on a libSceNet listener through the socket owner and stages the peer and length before the guest copy-out. In the changed hunks and the head context I read, I found no blocking defect. ## What I ran - Head `7b84f85167feab995efa4382a60f086f52242226`, base `main`. Static review only: no build and no tests were run. - Reader calls at head: ``` python3 <READER> search GuestCopyOut_nid_no_patch python3 <READER> search sceNetAccept python3 <READER> search "bool GuestCopyOut_nid_no_patch" python3 <READER> cat core/libs/prx/libc/src/General.cpp 826 836 python3 <READER> cat core/libs/prx/libkernel/Socket/src/Udp.cpp 536 556 python3 <READER> cat core/libs/prx/libkernel/Socket/src/Udp.cpp 1700 1808 python3 <READER> cat core/libs/prx/libSceNet/Export.cpp 309 340 python3 <READER> cat core/libs/prx/libSceNet/Export.cpp 1373 1440 python3 <READER> search Forwards ``` ## Results | Check | Result | Note | |---|---|---| | Copy-out bound | passed | `sceNetAccept` clamps to the guest capacity | | Positional `Forwards` init | passed | Only `g_socketForwards` initializes it | | Copy-out failure | passed | Accepted descriptor is closed | | Build and tests | not run | Author reports a Windows x64 run | ## Findings **Blocking** None. **Non-blocking** 1. `core/libs/prx/libkernel/Socket/src/Udp.cpp:1746`: the capacity clamp is not exercised. The test (`core/libs/tests/GuestNetKernelForwards.cpp:138`) always passes a 16-byte buffer for a 16-byte IPv4 peer, so no case covers a guest buffer shorter than the peer address. 2. `core/libs/tests/GuestNetKernelForwards.cpp:139`: the peer and size checks run before `Require(stream.accepted >= 0)` at line 140. A failed accept would show up as a peer mismatch rather than as an accept error. ## Not verified - The Windows x64 GCC 15.2 run of `guest_sce_net_kernel_forwards`, the combined socket and header checks, and the repository conventions check are author-reported. I did not run them. - The reference to #18166 is not checked. - The copy-out bound relies on `sceNetAccept` writing back the copied length, as read at `core/libs/prx/libSceNet/Export.cpp:333-335`. The path was not run on any platform. - Negative control: not run. - Files: all four changed files are in `files/`, but I did not read their full text. I read the diff hunks and the head ranges listed above. `files.json` was not read. ## To get this to a good state - Author: optionally add a test where the guest buffer is shorter than the peer address, and move the `accepted >= 0` check ahead of the size check. The Windows run listed above should be repeated on the new head if the code changes. ## Sources - Copy-out clamp: https://github.com/boykopovar/AnyPS5/blob/7b84f85167feab995efa4382a60f086f52242226/core/libs/prx/libSceNet/Export.cpp#L333-L335 - Socket accept path: https://github.com/boykopovar/AnyPS5/blob/7b84f85167feab995efa4382a60f086f52242226/core/libs/prx/libkernel/Socket/src/Udp.cpp#L1740-L1757
PrivacyOnion commented 2026-11-12 19:08:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-12T19:08:02Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against cbc6abf9ae:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_net_kernel_forwards_tests built cleanly.
  • CTest (guest_sce_net_kernel_forwards):
    1/1 Test #3867: guest_sce_net_kernel_forwards ....   Passed    0.24 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNet/Export.cpp, core/libs/prx/libkernel/Socket/include/SocketPoll.hpp, core/libs/prx/libkernel/Socket/src/Udp.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #3867: guest_sce_net_kernel_forwards ....Subprocess aborted***Exception:   0.50 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • core/libs/prx/libkernel/Socket/src/Udp.cpp: verified accept_nid_postfix performs proper guest memory validation using GuestCopyIn_nid_no_patch and GuestCopyOut_nid_no_patch, returning Fail(14) (EFAULT) if length is null or points to unmapped memory.
    • core/libs/prx/libkernel/Socket/src/Udp.cpp: verified peer address capacity clamping with std::minstd::uint32_t(capacity, sizeof(peer)) into a 28-byte stack buffer, properly accommodating both IPv4 (16 bytes) and IPv6 (28 bytes) addresses without buffer overruns.
    • core/libs/prx/libkernel/Socket/src/Udp.cpp: verified descriptor lifetime safety on guest copy-out failure, ensuring KernelCloseSocket_nid_no_patch closes the accepted socket before returning Fail(14) to prevent descriptor leaks.
    • core/libs/prx/libSceNet/Export.cpp: verified g_socketForwards struct initialization aligns with the Forwards struct layout in SocketPoll.hpp, correctly invoking sceNetAccept and translating negative return values into POSIX error codes via ErrorOf.
    • core/libs/tests/GuestNetKernelForwards.cpp: verified test coverage exercises loopback accept via kernel forwards, EFAULT on missing/invalid length pointers, successful address retrieval, and short buffer truncation with peerCapacity = 4.
    • Repository rules: verified compliance with AGENTS.md (zero code comments added, Conventional Commit title, no stray technical debt or report files added).
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5880444895 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18476#pullrequestreview-5880444895). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-12T19:08:02Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `cbc6abf9ae`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_net_kernel_forwards_tests` built cleanly. - **CTest** (`guest_sce_net_kernel_forwards`): ``` 1/1 Test #3867: guest_sce_net_kernel_forwards .... Passed 0.24 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNet/Export.cpp`, `core/libs/prx/libkernel/Socket/include/SocketPoll.hpp`, `core/libs/prx/libkernel/Socket/src/Udp.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #3867: guest_sce_net_kernel_forwards ....Subprocess aborted***Exception: 0.50 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - core/libs/prx/libkernel/Socket/src/Udp.cpp: verified accept_nid_postfix performs proper guest memory validation using GuestCopyIn_nid_no_patch and GuestCopyOut_nid_no_patch, returning Fail(14) (EFAULT) if length is null or points to unmapped memory. - core/libs/prx/libkernel/Socket/src/Udp.cpp: verified peer address capacity clamping with std::min<std::uint32_t>(capacity, sizeof(peer)) into a 28-byte stack buffer, properly accommodating both IPv4 (16 bytes) and IPv6 (28 bytes) addresses without buffer overruns. - core/libs/prx/libkernel/Socket/src/Udp.cpp: verified descriptor lifetime safety on guest copy-out failure, ensuring KernelCloseSocket_nid_no_patch closes the accepted socket before returning Fail(14) to prevent descriptor leaks. - core/libs/prx/libSceNet/Export.cpp: verified g_socketForwards struct initialization aligns with the Forwards struct layout in SocketPoll.hpp, correctly invoking sceNetAccept and translating negative return values into POSIX error codes via ErrorOf. - core/libs/tests/GuestNetKernelForwards.cpp: verified test coverage exercises loopback accept via kernel forwards, EFAULT on missing/invalid length pointers, successful address retrieval, and short buffer truncation with peerCapacity = 4. - Repository rules: verified compliance with AGENTS.md (zero code comments added, Conventional Commit title, no stray technical debt or report files added). - Note: the AI-assisted checkbox can stay. Looks Good To Me
PrivacyOnion commented 2026-11-12 23:20:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-12T23:20:12Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 5e705b6b4e:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_net_kernel_forwards_tests built cleanly.
  • CTest (guest_sce_net_kernel_forwards):
    1/1 Test #3879: guest_sce_net_kernel_forwards ....   Passed    0.23 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNet/Export.cpp, core/libs/prx/libkernel/Socket/include/SocketPoll.hpp, core/libs/prx/libkernel/Socket/src/Udp.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #3879: guest_sce_net_kernel_forwards ....Subprocess aborted***Exception:   0.49 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • core/libs/prx/libkernel/Socket/src/Udp.cpp:1745-1761: verified accept_nid_postfix correctly routes forwarded sockets through forwards->accept, validates guest memory via GuestCopyIn_nid_no_patch, bounds capacity with std::minstd::uint32_t, and closes the accepted descriptor via KernelCloseSocket_nid_no_patch if GuestCopyOut_nid_no_patch fails on address or length copy-out.
    • core/libs/prx/libSceNet/Export.cpp:1131-1135: verified g_socketForwards implements accept forwarder targeting sceNetAccept, extracting POSIX errno via ErrorOf(accepted) and matching KernelSocketPoll::Forwards signature.
    • core/libs/prx/libkernel/Socket/include/SocketPoll.hpp:30: verified struct Forwards field positioning (family, bind, getsockname, accept, sendto, recvfrom) aligns with aggregate initialization in g_socketForwards across translation units.
    • core/libs/prx/libkernel/Socket/src/Udp.cpp:1745: verified pointer validation semantics, returning Fail(14) (EFAULT) for null length with non-null address or unreadable guest memory, while safely permitting null address and length when peer address is not requested.
    • core/libs/tests/GuestNetKernelForwards.cpp:145-155,244-245: verified unit tests exercise accept_nid_postfix on forwarded libSceNet sockets, negative EFAULT paths, 16-byte loopback peer verification, and truncated 4-byte buffer handling.
    • AGENTS.md compliance: verified all modified files contain zero code comments outside allowed end-markers, no stubs or made-up return codes are introduced, and conventional commit naming is followed.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5883540963 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18476#pullrequestreview-5883540963). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-12T23:20:12Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `5e705b6b4e`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_net_kernel_forwards_tests` built cleanly. - **CTest** (`guest_sce_net_kernel_forwards`): ``` 1/1 Test #3879: guest_sce_net_kernel_forwards .... Passed 0.23 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNet/Export.cpp`, `core/libs/prx/libkernel/Socket/include/SocketPoll.hpp`, `core/libs/prx/libkernel/Socket/src/Udp.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #3879: guest_sce_net_kernel_forwards ....Subprocess aborted***Exception: 0.49 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - core/libs/prx/libkernel/Socket/src/Udp.cpp:1745-1761: verified accept_nid_postfix correctly routes forwarded sockets through forwards->accept, validates guest memory via GuestCopyIn_nid_no_patch, bounds capacity with std::min<std::uint32_t>, and closes the accepted descriptor via KernelCloseSocket_nid_no_patch if GuestCopyOut_nid_no_patch fails on address or length copy-out. - core/libs/prx/libSceNet/Export.cpp:1131-1135: verified g_socketForwards implements accept forwarder targeting sceNetAccept, extracting POSIX errno via ErrorOf(accepted) and matching KernelSocketPoll::Forwards signature. - core/libs/prx/libkernel/Socket/include/SocketPoll.hpp:30: verified struct Forwards field positioning (family, bind, getsockname, accept, sendto, recvfrom) aligns with aggregate initialization in g_socketForwards across translation units. - core/libs/prx/libkernel/Socket/src/Udp.cpp:1745: verified pointer validation semantics, returning Fail(14) (EFAULT) for null length with non-null address or unreadable guest memory, while safely permitting null address and length when peer address is not requested. - core/libs/tests/GuestNetKernelForwards.cpp:145-155,244-245: verified unit tests exercise accept_nid_postfix on forwarded libSceNet sockets, negative EFAULT paths, 16-byte loopback peer verification, and truncated 4-byte buffer handling. - AGENTS.md compliance: verified all modified files contain zero code comments outside allowed end-markers, no stubs or made-up return codes are introduced, and conventional commit naming is followed. - Note: the AI-assisted checkbox can stay. Looks Good To Me
MarcZX10 commented 2026-11-14 00:26:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T00:26:45Z.

Review: COMMENTED


Reviewed — no blocking findings

The changed code routes libSceNet accept through the socket owner and stages peer data before guest copy-out; I found no verified blocking defect.

What I ran

Reviewed head 5e705b6b4ebf752bd28ced12df381f801c0b18a6 using the pinned repo_read.py reader. I did not run build or test commands; the Windows x64 results in the description are author-reported.

Results

Check Result Note
Changed code review passed All four changed files and added lines read
Build and tests not run Author-reported checks were not independently run
Negative control not run No negative control was run

Findings

Blocking

None verified.

Non-blocking

None.

Not verified

Build and test results, retail title behavior, and physical-console behavior were not independently verified. The description reports no retail title run. No changed files were excluded; files.json was not listed in the review folder.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5899981114 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18476#pullrequestreview-5899981114). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T00:26:45Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The changed code routes libSceNet accept through the socket owner and stages peer data before guest copy-out; I found no verified blocking defect. ## What I ran Reviewed head `5e705b6b4ebf752bd28ced12df381f801c0b18a6` using the pinned `repo_read.py` reader. I did not run build or test commands; the Windows x64 results in the description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | All four changed files and added lines read | | Build and tests | not run | Author-reported checks were not independently run | | Negative control | not run | No negative control was run | ## Findings ### Blocking None verified. ### Non-blocking None. ## Not verified Build and test results, retail title behavior, and physical-console behavior were not independently verified. The description reports no retail title run. No changed files were excluded; `files.json` was not listed in the review folder. ## To get this to a good state Nothing is required.
PrivacyOnion commented 2026-11-16 05:39:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T05:39:57Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 7c5e021920:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_net_kernel_forwards_tests built cleanly.
  • CTest (guest_sce_net_kernel_forwards):
    1/1 Test #4398: guest_sce_net_kernel_forwards ....   Passed    0.21 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNet/Export.cpp, core/libs/prx/libkernel/Socket/include/SocketPoll.hpp, core/libs/prx/libkernel/Socket/src/Udp.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #4398: guest_sce_net_kernel_forwards ....Subprocess aborted***Exception:   0.24 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • core/libs/prx/libkernel/Socket/include/SocketPoll.hpp:31: verified struct Forwards adds the accept callback in the expected positional order matching aggregate initialization in g_socketForwards.
    • core/libs/prx/libSceNet/Export.cpp:1140-1144: verified the g_socketForwards accept lambda delegates to sceNetAccept, sets *error = ErrorOf(accepted), and returns the accepted descriptor.
    • core/libs/prx/libkernel/Socket/src/Udp.cpp:1817-1829: verified accept_nid_postfix validates non-null address capacity via GuestCopyIn_nid_no_patch (returning EFAULT=14 on failure), stages up to 28 bytes of peer address into a local stack buffer, reports the address via ReportAddress, and closes the accepted descriptor via KernelCloseSocket_nid_no_patch if copy-out fails.
    • core/libs/tests/GuestNetKernelForwards.cpp:142-163,252-253: verified unit tests cover accept_nid_postfix on libSceNet sockets, EFAULT (14) on null or unmapped length pointer, full 16-byte IPv4 peer copy-out, and truncated 4-byte peer buffer boundary preservation.
    • LP64/LLP64 portability & AGENTS.md compliance: verified explicit std::minstd::uint32_t template argument avoids size_t/uint32_t mismatch across Windows and Linux, and no comments or forbidden constructs were introduced.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5915495431 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18476#pullrequestreview-5915495431). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-16T05:39:57Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `7c5e021920`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_net_kernel_forwards_tests` built cleanly. - **CTest** (`guest_sce_net_kernel_forwards`): ``` 1/1 Test #4398: guest_sce_net_kernel_forwards .... Passed 0.21 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNet/Export.cpp`, `core/libs/prx/libkernel/Socket/include/SocketPoll.hpp`, `core/libs/prx/libkernel/Socket/src/Udp.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #4398: guest_sce_net_kernel_forwards ....Subprocess aborted***Exception: 0.24 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - core/libs/prx/libkernel/Socket/include/SocketPoll.hpp:31: verified struct Forwards adds the accept callback in the expected positional order matching aggregate initialization in g_socketForwards. - core/libs/prx/libSceNet/Export.cpp:1140-1144: verified the g_socketForwards accept lambda delegates to sceNetAccept, sets *error = ErrorOf(accepted), and returns the accepted descriptor. - core/libs/prx/libkernel/Socket/src/Udp.cpp:1817-1829: verified accept_nid_postfix validates non-null address capacity via GuestCopyIn_nid_no_patch (returning EFAULT=14 on failure), stages up to 28 bytes of peer address into a local stack buffer, reports the address via ReportAddress, and closes the accepted descriptor via KernelCloseSocket_nid_no_patch if copy-out fails. - core/libs/tests/GuestNetKernelForwards.cpp:142-163,252-253: verified unit tests cover accept_nid_postfix on libSceNet sockets, EFAULT (14) on null or unmapped length pointer, full 16-byte IPv4 peer copy-out, and truncated 4-byte peer buffer boundary preservation. - LP64/LLP64 portability & AGENTS.md compliance: verified explicit std::min<std::uint32_t> template argument avoids size_t/uint32_t mismatch across Windows and Linux, and no comments or forbidden constructs were introduced. Looks Good To Me
PrivacyOnion commented 2026-11-16 07:58:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T07:58:43Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against f6d22f5abc:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_net_kernel_forwards_tests built cleanly.
  • CTest (guest_sce_net_kernel_forwards):
    1/1 Test #4417: guest_sce_net_kernel_forwards ....   Passed    0.41 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNet/Export.cpp, core/libs/prx/libkernel/Socket/include/SocketPoll.hpp, core/libs/prx/libkernel/Socket/src/Udp.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #4417: guest_sce_net_kernel_forwards ....Subprocess aborted***Exception:   0.33 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • core/libs/prx/libkernel/Socket/include/SocketPoll.hpp:33: verified KernelSocketPoll::Forwards adds the accept callback in positional alignment with g_socketForwards aggregate initialization.
    • core/libs/prx/libSceNet/Export.cpp:1143-1147: verified g_socketForwards accept callback delegates to sceNetAccept, sets *error = ErrorOf(accepted), and returns the accepted descriptor.
    • core/libs/prx/libkernel/Socket/src/Udp.cpp:1821-1833: verified accept_nid_postfix validates non-null address capacity via GuestCopyIn_nid_no_patch (returning Fail(14) on EFAULT), clamps staging buffer size to 28 bytes using std::minstd::uint32_t, reports the address via ReportAddress, and closes the accepted descriptor via KernelCloseSocket_nid_no_patch if copy-out fails.
    • core/libs/tests/GuestNetKernelForwards.cpp:152-172,307-308: verified unit tests cover accept_nid_postfix on libSceNet sockets, EFAULT (14) on null or unmapped length pointers, full 16-byte IPv4 peer copy-out, and truncated 4-byte peer buffer boundary preservation.
    • LP64/LLP64 portability and AGENTS.md compliance: verified explicit std::minstd::uint32_t avoids size_t/uint32_t mismatch across Windows and Linux, and no comments or forbidden constructs were added.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5916663069 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18476#pullrequestreview-5916663069). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-16T07:58:43Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `f6d22f5abc`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_net_kernel_forwards_tests` built cleanly. - **CTest** (`guest_sce_net_kernel_forwards`): ``` 1/1 Test #4417: guest_sce_net_kernel_forwards .... Passed 0.41 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNet/Export.cpp`, `core/libs/prx/libkernel/Socket/include/SocketPoll.hpp`, `core/libs/prx/libkernel/Socket/src/Udp.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #4417: guest_sce_net_kernel_forwards ....Subprocess aborted***Exception: 0.33 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - core/libs/prx/libkernel/Socket/include/SocketPoll.hpp:33: verified KernelSocketPoll::Forwards adds the accept callback in positional alignment with g_socketForwards aggregate initialization. - core/libs/prx/libSceNet/Export.cpp:1143-1147: verified g_socketForwards accept callback delegates to sceNetAccept, sets *error = ErrorOf(accepted), and returns the accepted descriptor. - core/libs/prx/libkernel/Socket/src/Udp.cpp:1821-1833: verified accept_nid_postfix validates non-null address capacity via GuestCopyIn_nid_no_patch (returning Fail(14) on EFAULT), clamps staging buffer size to 28 bytes using std::min<std::uint32_t>, reports the address via ReportAddress, and closes the accepted descriptor via KernelCloseSocket_nid_no_patch if copy-out fails. - core/libs/tests/GuestNetKernelForwards.cpp:152-172,307-308: verified unit tests cover accept_nid_postfix on libSceNet sockets, EFAULT (14) on null or unmapped length pointers, full 16-byte IPv4 peer copy-out, and truncated 4-byte peer buffer boundary preservation. - LP64/LLP64 portability and AGENTS.md compliance: verified explicit std::min<std::uint32_t> avoids size_t/uint32_t mismatch across Windows and Linux, and no comments or forbidden constructs were added. Looks Good To Me
MarcZX10 commented 2026-11-22 08:41:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T08:41:15Z.

Review: DISMISSED


Reviewed — changes requested

Changes are required before merge: preserve the caller's peer-address capacity when the forwarded accept reports the copied length.

What I ran

Reviewed head cf6b8be4c78e2cf6f2cc2283572b96a0a17ede5e using repo_read.py through the pinned review reader. No tests or builds were run. I read description.md, commits.md, manifest.json, diff.patch, and the full text of all four changed files listed in the manifest.

Results

Check Result Note
Changed code review failed Forwarded address-length handling is incorrect
Build and tests not run Author reports a Windows x64 GCC 15.2 run

Findings

Blocking

  • core/libs/prx/libkernel/Socket/src/Udp.cpp:1858 initializes size to min(capacity, sizeof(peer)), then passes it to sceNetAccept, which updates it with the peer address length. ReportAddress uses that same value as its copy-out limit. With a short caller buffer, the returned length is therefore the truncated copy size, rather than the original capacity/required address length; e.g. a 4-byte buffer can be reported as length 4 instead of 16 for IPv4. Preserve the input capacity separately and report the correct output length while limiting the address copy to the caller's capacity.

Non-blocking

None.

Not verified

Build and test results described in the PR body were not independently verified. No runtime behavior on Windows, other host operating systems, or a retail title was verified.

To get this to a good state

Preserve the original peer-address capacity separately from the output length, then rerun the forwarded accept tests, including short-buffer behavior.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6011302299 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18476#pullrequestreview-6011302299). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T08:41:15Z. **Review:** DISMISSED --- # Reviewed — changes requested Changes are required before merge: preserve the caller's peer-address capacity when the forwarded accept reports the copied length. ## What I ran Reviewed head `cf6b8be4c78e2cf6f2cc2283572b96a0a17ede5e` using `repo_read.py` through the pinned review reader. No tests or builds were run. I read `description.md`, `commits.md`, `manifest.json`, `diff.patch`, and the full text of all four changed files listed in the manifest. ## Results | Check | Result | Note | |---|---|---| | Changed code review | failed | Forwarded address-length handling is incorrect | | Build and tests | not run | Author reports a Windows x64 GCC 15.2 run | ## Findings ### Blocking - `core/libs/prx/libkernel/Socket/src/Udp.cpp:1858` initializes `size` to `min(capacity, sizeof(peer))`, then passes it to `sceNetAccept`, which updates it with the peer address length. `ReportAddress` uses that same value as its copy-out limit. With a short caller buffer, the returned length is therefore the truncated copy size, rather than the original capacity/required address length; e.g. a 4-byte buffer can be reported as length 4 instead of 16 for IPv4. Preserve the input capacity separately and report the correct output length while limiting the address copy to the caller's capacity. ### Non-blocking None. ## Not verified Build and test results described in the PR body were not independently verified. No runtime behavior on Windows, other host operating systems, or a retail title was verified. ## To get this to a good state Preserve the original peer-address capacity separately from the output length, then rerun the forwarded accept tests, including short-buffer behavior.
MarcZX10 commented 2026-11-25 11:13:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T11:13:35Z.

Review: COMMENTED


Reviewed — no blocking findings

The reviewed change routes accept for libSceNet sockets through their owner and stages the peer address before applying the caller’s capacity; I found no concrete blocking defect in the changed code.

What I ran

Reviewed head 7038be4e730d96999e6abbc4321263369858cb3d using the prepared diff and pinned repository reader. No build or test command was run in this review. I read every changed line in all five changed files; no changed files were excluded.

Results

Check Result Note
Changed code review passed All five changed files read
Build and tests not run Author reports Windows tests; not run here
Negative control not run Author reports a negative-control run

Negative control

Not run in this review. The author reports that removing the capacity limit makes the capacity assertion fail, then passes after restoring it; this was not independently verified.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

No local build, tests, Linux/macOS runtime, PS5 hardware, or retail title run was performed. The reported Windows test results and negative control are author-supplied, not independently confirmed.

To get this to a good state

Nothing is required. Optional: measure the peer-address length policy on PS5, as recorded in the debt note.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6056571038 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18476#pullrequestreview-6056571038). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T11:13:35Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The reviewed change routes `accept` for `libSceNet` sockets through their owner and stages the peer address before applying the caller’s capacity; I found no concrete blocking defect in the changed code. ## What I ran Reviewed head `7038be4e730d96999e6abbc4321263369858cb3d` using the prepared diff and pinned repository reader. No build or test command was run in this review. I read every changed line in all five changed files; no changed files were excluded. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | All five changed files read | | Build and tests | not run | Author reports Windows tests; not run here | | Negative control | not run | Author reports a negative-control run | ## Negative control Not run in this review. The author reports that removing the capacity limit makes the capacity assertion fail, then passes after restoring it; this was not independently verified. ## Findings ### Blocking None. ### Non-blocking None. ## Sources - [Changed `accept` forwarding and capacity handling](https://github.com/boykopovar/AnyPS5/blob/7038be4e730d96999e6abbc4321263369858cb3d/core/libs/prx/libkernel/Socket/src/Udp.cpp#L1853-L1867) - [Forwarded `sceNetAccept` implementation](https://github.com/boykopovar/AnyPS5/blob/7038be4e730d96999e6abbc4321263369858cb3d/core/libs/prx/libSceNet/Export.cpp#L1430-L1503) ## Not verified No local build, tests, Linux/macOS runtime, PS5 hardware, or retail title run was performed. The reported Windows test results and negative control are author-supplied, not independently confirmed. ## To get this to a good state Nothing is required. Optional: measure the peer-address length policy on PS5, as recorded in the debt note.
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!18476
No description provided.