fix(libkernel): getsockopt reads options of libSceNet sockets #9515
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9515"
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 EagleBearerYS on 2026-10-22T00:00:15Z.
Title-less conformance fixes of this kind are merged now, for example #7365 and #8411.
What
setsockoptreaches a socket created withsceNetSocketthrough the option setter libSceNet registers with libkernel, butgetsockoptlooks the descriptor up only among libkernel's own sockets and fails. A title can set an option on such a socket through the BSD call and not read it back.getsockoptasks it for a descriptor libkernel doesn't own, assetsockoptdoes. The getter answers throughsceNetGetsockopt, soSO_RCVTIMEOandSO_SNDTIMEOcome back as astruct timeval, as FreeBSD 11.4'ssogetoptreturns them.SO_REUSEADDRandSO_BROADCASTread back throughsceNetGetsockoptas Queuse's #9542 made them onmain, 0x4 and 0x20 when set, as FreeBSD'ssogetoptreturns them. Through the getter, libkernel'sgetsockoptanswers them for a libSceNet socket too.getsockoptwithsetsockopt.Two commits:
e887616e74forsceNetGetsockopt,aea804d9fdfor the libkernel getter and the debt entry.4432e8aa57, a merge ofmain, drops e887616e74'ssceNetGetsockoptreadback, which #9542 now has onmain. No title is claimed.Overlap: #9365 has merged, and this PR's addition of
getsockoptto itscloseandsetsockoptdebt sentence sits on top. #7511, which added pointer and length checks at the start ofgetsockopt_nid_postfix, was closed without merging. #9542 (Queuse) has merged, with the sameSO_REUSEADDRandSO_BROADCASTreadback insceNetGetsockoptand short-buffer handling. As agreed with Queuse in this thread (comment), this PR's merge ofmain(4432e8aa57) drops e887616e74's copy of that readback, which would otherwise put the same twocaselabels in one switch, and keeps the libkernel getter forwarding and its tests.Tested
On GitHub's runners from my fork, on
mainata6dcea9279(run, of the same code;aea804d9fdadds the debt edit only):guest_sce_net, on a datagram socket made withsceNetSocket:sceNetGetsockoptreadsSO_BROADCASTandSO_REUSEADDRback as 0x20 and 0x4 aftersceNetSetsockoptsets them;getsockoptreadsSO_BROADCASTback as 0x20;setsockoptsetsSO_RCVTIMEOto 0.25 s, libkernel'sgetsockoptreturns the samestruct timeval.main's codeguest_sce_netfails on Linux and Windows. With the change it passes 10 runs in a row on both.core/libs/prx/libcandcore/libs/prx/libkernelpasses: 142 and 207 on Windows, 197 libkernel tests on Linux. In the Linux libc suite (115), the timing testprecise_waitfailed with and without the change in this run.tools/check_conventions.py --base origin/mainpasses.a6dcea9279.guest_sce_netpasses 3 of 3, and with libSceNet'sExport.cppand libkernel'sSocketPoll.hpp,Socket.cppandUdp.cppat the merge base and the PR's tests kept, it aborts.efd999c8ed, a merge ofmain938812df14. The only conflict wasdocs/dev/debt/libkernel.md, wheremainreworded thesceKernelPreadline next to this PR'scloseandgetsockoptline; both changes are kept, and the PR's own diff is unchanged. On GitHub's runners (run),guest_sce_net,guest_socket_options,guest_socket_errorandguest_socket_descriptor_flagspass 10 runs in a row on Linux and on Windows, 4 of 4, none skipped. The libc and libkernel suites pass on both (119 and 201 tests on Linux, 146 and 211 on Windows), run withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.abbb7ac6b5, a merge ofmain67bbe03f91. The only conflict wasdocs/dev/debt/libkernel.md, where #9099 (aarushkha, regular-file events) reworded thesceKernelAddReadEventpipe entry and added its own regular-file entry just above this PR'sclose,setsockoptandgetsockoptline; the merge keeps both ofmain's entries and this PR's line, and the PR's own diff is unchanged. On GitHub's runners (run),guest_sce_net,guest_socket_options,guest_socket_errorandguest_socket_descriptor_flagspass 10 runs in a row with the change, on Linux and on Windows: 4 run, 4 pass, 0 skip, 0 fail. Withmain's code,guest_sce_netfails on both. The libc and libkernel suites pass on both (143 and 205 tests on Linux, 170 and 218 on Windows), run withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.fc47c2f491, a merge ofmaina512780d58. The one conflict was incore/libs/tests/GuestSceNet.cpp, where #10706 (the public-header migration) removed the test's local declarations, among them this PR'sgetsockopt_nid_postfix. The merge takesmain's side, since libkernel'sinclude/Api.hppnow declaresgetsockopt_nid_postfixwith the same arguments. It also drops this PR's localsceNetGetsockoptdeclaration in libSceNet'sExport.cpp, whichtests/test_public_headers.py --audit-onlyreports as a second declaration next toNet.hpp's. So the PR's own diff loses those two declarations and is otherwise unchanged. On GitHub's runners (run),guest_sce_net,guest_socket_options,guest_socket_error,guest_socket_descriptor_flagsandpublic_headerspass 10 runs in a row with the change, on Linux and on Windows: 5 run, 5 pass, 0 skip, 0 fail. Withmain's code,guest_sce_netfails on both. The libc and libkernel suites pass on both (143 and 206 tests on Linux, 170 and 222 on Windows), run withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.00924d8f9f, a merge ofmain66e6772ca2(run). The one conflict wasdocs/dev/debt/libkernel.md's entry on libSceNet sockets, wheremainaddspollandfcntland this PR addsgetsockopt; the merge keeps both, in the same words as #9578's merge. The PR's code diff is unchanged.guest_sce_net,guest_socket_descriptor_flags,guest_socket_error,guest_socket_optionsandpublic_headerspass 10 runs in a row. Linux: 5 run, 5 pass, 0 skip, 0 fail. Windows: 5 run, 5 pass, 0 skip, 0 fail. The before arm failsguest_sce_neton both. Suites: libc and libkernel pass on Linux (144 and 207) and on Windows (171 and 223). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.4432e8aa57, a merge ofmain68200c47ea(run). There was no text conflict, but with Queuse's #9542 onmain,sceNetGetsockopt's switch had two identicalcase NET_SO_REUSEADDR: case NET_SO_BROADCAST:blocks and didn't build ("duplicate case value"). The merge drops this PR's block and keepsmain's, with its short-buffer check; this PR's other changed lines are the same.guest_net_boolean_readback,guest_sce_net,guest_socket_descriptor_flags,guest_socket_error,guest_socket_optionsandpublic_headerspass 10 runs in a row. Linux: 6 run, 6 pass, 0 skip, 0 fail. Windows: 6 run, 6 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (166 and 264). On Windows libc passes (194) and libkernel passes 283 of 286:exec_arguments,guest_timed_join_import_libkernel_sysandguest_timed_join_import_libkernel_webfail at their setup in the verify's Windows build (FileNotFoundErrorstarting the title, or copying the libraries they load), withmain's code too, and pass inmain's own Windows job at1829def9bf(job). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.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 MarcZX10 on 2026-10-22T00:06:52Z.
Review: CHANGES_REQUESTED
The socket-hook change and the reported Windows/Linux tests look promising, but the checklist currently says
Depends on: nonewhile the PR description identifies two live overlaps.CONTRIBUTING.mdrequires overlap authors to agree on merge order and declare the dependency. Thegetsockopt_nid_postfixhunk overlaps open #7511, which validates pointer/length ordering in the same function; this PR inserts the libSceNet dispatch before that function’s current lookup. Thedocs/dev/debt/libkernel.mdhunk overlaps open #9365 on the same socket-call sentence. Please coordinate with both authors, identify the agreed order, and update the checklist (and #9365’s “no open pull request edits these sentences” statement) before merge. I am not asking for a code change based on the reviewed diff.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T00:40:29Z.
Thanks, @MarcZX10. This PR goes after both: Depends on now lists #7511 and #9365, and I've left a note on each. When it rebases on #7511, the libSceNet getter call moves after #7511's pointer and length checks, so a libSceNet socket fails those the same way libkernel's own sockets do. On #9365, this PR's addition of
getsockoptto thecloseandsetsockoptsentence goes on top of its correction, and the note there says that this PR also edits that sentence. The Overlap line in the description now gives the order.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:17:42Z.
Review: APPROVED
Re-reviewed the updated full body and diff after the author recorded the shared
getsockopt/debt ordering with #7511 and #9365. The new getter registration is adjacent to the existing setter bridge, and the reported tests exercise the net-specific and libkernel dispatch paths with the FreeBSD timeval representation. Current hosted checks and the reported cross-platform test suites support the change; I did not run a local build. The prior overlap coordination blocker is resolved.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T02:04:58Z.
Review: APPROVED
Rechecked the current head and the updated dependency coordination. The PR now declares #7511 and #9365, explains how the getter dispatch follows #7511 pointer/length checks, and records the shared debt sentence order with #9365. The tests cover libSceNet boolean reads and libkernel timeval dispatch; author reports repeated Linux/Windows red/green runs and broader suites, with one Linux timing test failing on both base and change. Hosted eligibility, conventions, intake, labels and report checks pass; product/relinker jobs are skipped. I did not run local tests.
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-22T03:15:07Z.
Linux data point for
aea804d9fd: WSL2 Ubuntu 24.04 (virtualised kernel, not bare-metal), GCC 13.3.0, Release,BUILD_TESTING=ON, PR head alone (not merged ontomain; its merge-base isa6dcea927).ctest -R '^guest_sce_net$'passes 3 of 3.libSceNet/Export.cpp, libkernel/Socket/include/SocketPoll.hpp, libkernel/Socket/src/Socket.cpp and libkernel/Socket/src/Udp.cpprestored to the merge-base (the PR's tests kept): fails (Subprocess aborted).Not tested: macOS, Windows, a title run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T03:20:49Z.
@xXPBSXx thanks for the Linux run, both red and green. It's in Tested now.