fix(libkernel): accept connections on libSceNet sockets #18476
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18476"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-11-11T17:37:33Z.
What
Route POSIX
acceptfor alibSceNetlistener 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_accept4andaccept1. 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.guest_sce_net_kernel_forwards,guest_kernel_web_forwards,guest_socket_connect_listening, andguest_kernel_socket_shutdown, each three consecutive times.cf6b8be4c7also passes this expanded matrix. The follow-up makes capacity handling explicit while preserving its existing FreeBSD-compatible results.guest_sce_net_kernel_forwardsfail at the capacity assertion. Restoring the limit passes all four suites again.git diff --checkand repository conventions against the upstream merge base passed. The required comparison with the stale fork'sorigin/mainincludes 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
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)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:tools/check_conventions.pypassed;git diff --checkclean.pipe-write (macos-15),pipe-write (macos-15-intel).guest_net_kernel_forwards_testsbuilt cleanly.guest_sce_net_kernel_forwards):core/libs/prx/libSceNet/Export.cpp,core/libs/prx/libkernel/Socket/include/SocketPoll.hpp,core/libs/prx/libkernel/Socket/src/Udp.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T14:27:23Z.
Review: COMMENTED
Reviewed — no blocking findings
The diff routes
accepton 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
7b84f85167feab995efa4382a60f086f52242226, basemain. Static review only: no build and no tests were run.Results
sceNetAcceptclamps to the guest capacityForwardsinitg_socketForwardsinitializes itFindings
Blocking
None.
Non-blocking
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.core/libs/tests/GuestNetKernelForwards.cpp:139: the peer and size checks run beforeRequire(stream.accepted >= 0)at line 140. A failed accept would show up as a peer mismatch rather than as an accept error.Not verified
guest_sce_net_kernel_forwards, the combined socket and header checks, and the repository conventions check are author-reported. I did not run them.sceNetAcceptwriting back the copied length, as read atcore/libs/prx/libSceNet/Export.cpp:333-335. The path was not run on any platform.files/, but I did not read their full text. I read the diff hunks and the head ranges listed above.files.jsonwas not read.To get this to a good state
accepted >= 0check ahead of the size check. The Windows run listed above should be repeated on the new head if the code changes.Sources
github.com/boykopovar/AnyPS5@7b84f85167/core/libs/prx/libSceNet/Export.cpp (L333-L335)github.com/boykopovar/AnyPS5@7b84f85167/core/libs/prx/libkernel/Socket/src/Udp.cpp (L1740-L1757)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:tools/check_conventions.pypassed;git diff --checkclean.guest_net_kernel_forwards_testsbuilt cleanly.guest_sce_net_kernel_forwards):core/libs/prx/libSceNet/Export.cpp,core/libs/prx/libkernel/Socket/include/SocketPoll.hpp,core/libs/prx/libkernel/Socket/src/Udp.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
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:tools/check_conventions.pypassed;git diff --checkclean.guest_net_kernel_forwards_testsbuilt cleanly.guest_sce_net_kernel_forwards):core/libs/prx/libSceNet/Export.cpp,core/libs/prx/libkernel/Socket/include/SocketPoll.hpp,core/libs/prx/libkernel/Socket/src/Udp.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
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
5e705b6b4ebf752bd28ced12df381f801c0b18a6using the pinnedrepo_read.pyreader. I did not run build or test commands; the Windows x64 results in the description are author-reported.Results
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.jsonwas not listed in the review folder.To get this to a good state
Nothing is required.
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:tools/check_conventions.pypassed;git diff --checkclean.guest_net_kernel_forwards_testsbuilt cleanly.guest_sce_net_kernel_forwards):core/libs/prx/libSceNet/Export.cpp,core/libs/prx/libkernel/Socket/include/SocketPoll.hpp,core/libs/prx/libkernel/Socket/src/Udp.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
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:tools/check_conventions.pypassed;git diff --checkclean.guest_net_kernel_forwards_testsbuilt cleanly.guest_sce_net_kernel_forwards):core/libs/prx/libSceNet/Export.cpp,core/libs/prx/libkernel/Socket/include/SocketPoll.hpp,core/libs/prx/libkernel/Socket/src/Udp.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
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
cf6b8be4c78e2cf6f2cc2283572b96a0a17ede5eusingrepo_read.pythrough the pinned review reader. No tests or builds were run. I readdescription.md,commits.md,manifest.json,diff.patch, and the full text of all four changed files listed in the manifest.Results
Findings
Blocking
core/libs/prx/libkernel/Socket/src/Udp.cpp:1858initializessizetomin(capacity, sizeof(peer)), then passes it tosceNetAccept, which updates it with the peer address length.ReportAddressuses 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.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T11:13:35Z.
Review: COMMENTED
Reviewed — no blocking findings
The reviewed change routes
acceptforlibSceNetsockets 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
7038be4e730d96999e6abbc4321263369858cb3dusing 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
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
acceptforwarding and capacity handlingsceNetAcceptimplementationNot 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.