fix(libkernel): forward socket calls on sceNetSocket descriptors to libSceNet #14310
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14310"
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 XatiX on 2026-11-01T09:17:32Z.
What
A title can create a socket with
sceNetSocketand then callbind,getsockname,sendtoorrecvfromfrom libkernel. libkernel does not hold that descriptor, so these calls failed withEBADF.libSceNet now registers the four calls with libkernel, in the same shape #9515 used for
getsockopt: libkernel asks only for a descriptor it does not hold, and any descriptor libSceNet does not own still reportsEBADF. Each call runs libkernel's validation before it forwards, so a forwarded descriptor keeps the libkernel contract: the same errors, safe guest-address handling andMSG_WAITALL. The differences that remain are in the debt entry.This is what stopped PPSA06866. RakNet opens its socket through
sceNetSocket, so the title's local server failed withAbstractPeer::Init: Failed to bind socket to port in range 0 - 0, and the load after difficulty selection never ended.Tested
Windows 11 Pro 10.0.26300, GCC 15.2.0 (WinLibs).
guest_sce_net_kernel_forwardsruns one set of checks through the libkernel calls on sockets from bothsocket()andsceNetSocket: a loopback datagram, null arguments, address lengths, unreadable pointers, flags, a zero-length receive, and streamMSG_WAITALLacross two sends and end of stream. It also checks unknown descriptors. It passes. Against the previous forwarding code it fails at the first nullbindon a forwarded socket.guest_sce_net|guest_net|net_epoll|guest_udp|guest_socket|guest_tcp|guest_datagrampass onmainf2d874c1fd.mainstops earlier, at the unsupported stencil copy, so the title cannot reach this code there. On a local branch that also carries #9717 and #13021 plus this commit, the title started its local server and reached play, with no bind failure in itsnetwork.logand the local client connected. That branch differs from this one. It is not evidence that the title runs onmain.connectandlistenare not forwarded. The title does not need them and they are not tested.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)main🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T09:04:04Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The forwarding implementation is scoped, but it conflicts with two open socket PRs and the repository requires the authors to coordinate their landing order.
What I ran
Reviewed head
c061c4391bd8e3ead28c0077c0d4a329ca068490against PR base5c9837bfe7c5533f2c77c968dd8193157a8c342a. The stack precheck also previewed it cleanly against currentmain26fa1212b82f76dd49cf12d65e445d6ff3e0844c. Pairwise previews used #9948 head52566995bb14259fd9b1da51fb7879a523ce1ef8(merge base3fea2a937ba9fbab2f06c51691fe0c5763659aa3) and #11281 head09746b556e6fca208357b1cb60c397a5e06125a8(merge baseacb900c194325b9ee8c23c10768a9a491454f0b2). Those previews conflict inSocketPoll.hppandUdp.cpp, respectively. Environment: Linux 6.1.0-54-amd64; no compiler was invoked. I did not configure, build, or run local CTest.Results
RunNetThreaddeclaration warning is outside this diff; the symbol is unchanged.GuestNetKernelForwards.cppas a test executable and registersguest_sce_net_kernel_forwards.mainSocketPoll.hpp; #11281 conflicts inUdp.cpp.guest_sce_net_kernel_forwardstest passed in the Windows CTest run. Linux and specialized jobs were skipped.The precheck's aggregate status was
checks failedbecause its detached exact-head checkout does not contain the workspace-only ABI and test-quality helper scripts. I reran the applicable helpers from the workspace and inspected their findings against the exact-head diff and CMake registration.Unedited output excerpts from the relevant checks
Negative control
sceNetSocketdescriptorsFindings
Blocking
SocketPoll.hppwith #9948 andUdp.cppwith #11281. The repository says authors of overlapping PRs should agree which goes first and declare that order withDepends on; this PR currently saysDepends on: none. Please coordinate with both authors and update the dependency/landing-order line and branch so the changes integrate cleanly.Non-blocking
Sources
getsocknamechange in #11281 at its current headNot verified
To get this to a good state
Coordinate the order with #9948 and #11281, declare any resulting dependency, and update the branch to integrate with the chosen order. I will re-check the new head, repeat the no-build checks, and inspect the CI result for the updated head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T18:29:25Z.
Review: COMMENTED
Reviewed — no blocking findings
The six-file change has no blocking source defect in the reviewed head; I am withholding approval because the Linux runtime path was skipped and this change adds Linux socket forwarding behavior.
What I ran
Reviewed every changed file at head
7a4fa3865bbf3d4d5b0d65a2be3f2e8cdcac5a98, against PR basea4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8. The stack precheck reported a clean merge preview against currentmainat that same base. Final refresh confirmed the PR remained open at the same head and base.Environment: Debian 12, Linux 6.1.0-54-amd64, Python 3.11.2, GCC 12.2.0 (not used for a build).
The ABI audit and test-quality helper were rerun from the workspace because those optional scripts are absent from the isolated PR snapshot used by the precheck. I confirmed the test is registered in the changed CMake file despite the heuristic warning. I did not configure or build AnyPS5, run local CTest, or run a negative control.
Results
main.Precheck summary and selected raw outputs
Precheck table (from its report):
Conventions output:
Standalone ABI audit summary:
Test-quality output (the CMake registration was manually confirmed):
Hosted Windows log for the new test:
gh pr checksreportedpassfor conventions, labels, library-portability, report, eligibility and Windows; Linux, relinker, ASan, edge-watch, register-context and write-watch wereskipping.Negative control
Findings
Blocking
None found in the six changed files.
Non-blocking
guest_sce_net_kernel_forwardson this head before approval. The Windows job passed, but Linux execution of the new forwarding and socket handling was skipped; the author's Linux test evidence is formain, not this change.Sources
Not verified
To get this to a good state
Run
ctest --test-dir build -R '^guest_sce_net_kernel_forwards$' --output-on-failureon Linux at this head and provide the result. I will recheck the current head and repeat the no-build review checks if the PR changes.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T19:31:49Z.
Review: CHANGES_REQUESTED
Re-checked — same head, changes requested
The supplied Linux logs address the skipped runtime path, but the current head of open PR #9948 conflicts with this PR's debt-file edit and no landing order is recorded.
What I ran
Rechecked PR #14310 at head
7a4fa3865bbf3d4d5b0d65a2be3f2e8cdcac5a98against basea4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8. The full six-file source review was posted earlier on this same head; this follow-up verifies the newly supplied Linux logs and the live overlap with #9948. Both PRs merge individually into currentmain, but the pairwise preview conflicts indocs/dev/debt/libSceNet.md. Environment: Debian Linux x86_64, Git 2.39.5. I did not build locally.Results
Pairwise merge output
Negative control
I made no code mutation. The author reports that the regression test failed against the previous forwarding implementation; I did not independently repeat that control.
Findings
Blocking
sceNetGetSockInfotechnical-debt entry. The current heads conflict in that shared paragraph when combined, although each merges individually into currentmain.CONTRIBUTING.mdrequires authors with overlapping changes to agree which lands first and record the order. Please coordinate with #9948's author and updateDepends onon whichever PR is second; preserve both sets of debt information when resolving the paragraph.Non-blocking
None.
Sources
Not verified
I did not rerun the C++ tests locally; the Linux logs are author-provided, and the Windows result is hosted CI. Linux GitHub Actions, console behavior, and the negative control were not independently run by me.
To get this to a good state
Agree and record the landing order with #9948's author, then resolve the shared debt paragraph without losing either measurement. I will rerun the pairwise preview and review any changed head.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T22:23:52Z.
Review: APPROVED
Reviewed — approved
libkernel's
bind,getsockname,sendtoandrecvfromnow reachsceNetSocketdescriptors and run libkernel's validation first. On Linux the new test passes, it fails againstmain's production files, and I found nothing blocking.What I ran
Head
7a4fa3865bbf3d4d5b0d65a2be3f2e8cdcac5a98, merged with--no-ffintomain9090972b7e91fd266819cbd77a8b058e177b5682(merged tree77ff4a4093ac88a49a1b492da9b5db0f961e3eea). Debian 13 VM, GCC 14.2.0, Release, Ninja,BUILD_TESTING=ON.Results
git diff --checkcheck_conventions.pylibs(script)main.guest_net_ctlis skipped onmaintoo.guest_socket_options_multicastfailed: it is on the known-failure list formain(the 224.0.0.251 join fails in this VM).guest_net_ctlwas skipped, as onmain.guest_sce_net_kernel_forwards--repeat until-fail:5git status --porcelainprinted nothing)Multicast failure (also fails on main)
Negative control
I restored
main'score/libs/prx/libSceNet/Export.cpp,core/libs/prx/libkernel/Socket/include/SocketPoll.hppandcore/libs/prx/libkernel/Socket/src/Udp.cpp, kept the PR's test and its registration, and rebuilt.guest_sce_net_kernel_forwardsthen fails:Line 53 is the first
bindon thesceNetSocketsocket. This matches what B-Howell reported on Windows and WSL2, now confirmed on a native Linux VM with GCC 14. After I restored the merged files and rebuilt, the test passed again.Findings
Blocking
None.
Non-blocking
docs/dev/debt/libkernel.md:205andcore/libs/prx/libkernel/Socket/src/Udp.cpp:278-282.ForwardsForforwards any descriptor that is not in libkernel's socket table and that libSceNet knows. The entry says a CRT file descriptor and a libSceNet socket can share a number, and that "closethen closes the socket". With this PR,bind,getsockname,sendtoandrecvfromon such a file descriptor also act on the socket instead of returningENOTSOCK.getsockoptalready did this (Udp.cpp:1341), so the risk itself is not new; only the entry's wording now understates it.close.mainthe unforwarded call fails withENOTSOCK(38), notEBADF, as the negative control above shows. The description could be updated.KernelWaitAll = 0x40incore/libs/prx/libSceNet/Export.cpp:947repeats libkernel'sGuestWaitAllvalue. This is minor and needs no action unless a shared header becomes available.On the earlier blocking finding about overlap with #9948 and #11281: the PR does not change
docs/dev/debt/libSceNet.md, and this tree merges cleanly into currentmain. I did not merge #9948 myself.Not verified