fix(libSceNet): follow FreeBSD 11.4's sys_ioctl for unhandled sceNetIoctl requests #22992
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22992"
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 brajankw on 2026-11-18T16:15:02Z.
What
sceNetIoctlon asceNetSocketsocket failed withENOTTYfor every request other thanFIONBIOandFIONREAD. This PR assumes, without a console measurement, that asceNetSocketsocket is a kernel socket and thatsceNetIoctlis theioctlsystem call on it. On that assumption, it now answers those requests the way FreeBSD 11.4'ssys_ioctlandsoo_ioctldo.ENOTTY. That is no direction bit, an input or output request of length 0, or anIOC_VOIDrequest whose length is neither 0 nor 4. libkernel'sIoctlRequestMalformedapplies the same rule, and the console gaveENOTTYfor0x8000667f. The rule is copied intolibSceNet/Export.cpp, since that function is internal to libkernel.IOC_INargument, other than anIOC_VOIDone, is copied in next, so an unreadable one fails withEFAULT. libkernel'sioctlon a guest socket does not copy one in yet, so there an unreadable non-null argument for an unknown request still givesEADDRNOTAVAIL.ENOTTY, thoughkern_ioctlorsoo_ioctlanswers them:FIOCLEX,FIONCLEX,FIOASYNC,FIOSETOWN,FIOGETOWN,FIONWRITE,FIONSPACE,SIOCATMARK,SIOCSPGRPandSIOCGPGRP. OnAF_INET6, so do theurequests 106 to 109, whichin6_controlhandles before its interface check. They are matched by group and number only, which is broader than FreeBSD's exact match. Nothing shows the console's answer for them, so they keep the error a title already handles; the debt entry lists them.i,randfrequests fail withENOTTY, as in libkernel. FreeBSD sendsiandrtoifioctlandrtioctl_fib. It has no special case forf;ENOTTYthere is libkernel's choice in the absence of a measurement.EADDRNOTAVAILonAF_INET, asin_controldoes with no interface. libkernel'sioctlgives the same, measured withTIOCGWINSZon a libkernelAF_INETsocket (#11219). OnAF_INET6, it fails withEOPNOTSUPP, asin6_controldoes and libkernel'stcgetattrpath already answers (File/src/Terminal.cpp). libkernel'sioctlstill givesEADDRNOTAVAILonAF_INET6; that is for a separate PR.FIONBIOandFIONREAD, and libkernel's own sockets reached throughsceNetIoctl, are unchanged. A bad socket id still fails withEBADFbefore the malformed-request check.GuestSceNet.cppCheckIoctl.AF_INETsceNetSocketsocket,TIOCGWINSZ,_IOW('x', 1, int),_IOWR('x', 1, int)and theIOC_VOID0x20047801fail withEADDRNOTAVAILand leave the argument unchanged.TIOCGWINSZand0x20047801also do so with a null argument.IOC_INargument fails withEFAULT, including forSIOCSPGRP.ENOTTY, one of them with an unreadable argument, which shows thatENOTTYcomes beforeEFAULT.kern_ioctlorsoo_ioctlanswers fail withENOTTYwithout touching the argument.FIODTYPE, anfrequest, fails withENOTTY, andSIOCAADDRCTL_POLICYfails withEADDRNOTAVAILonAF_INET.ioctlon the socket givesEADDRNOTAVAILforTIOCGWINSZ.AF_INET6socket, three requests fail withEOPNOTSUPP, andSIOCAADDRCTL_POLICYfails withENOTTY.123(ENOTTY) still hold.sceNetIoctlentry drops "other requests fail withENOTTY, as in libkernel'sioctl". A new entry leads with the assumption and lists these rules, including theAF_INET6difference from libkernel.Tested
Linux (Debian 13, GCC 14.2.0, Release). This branch was first tested on
main68f3159e41, with the change as the single commit on it. After review, the ten requests andu106 to 109 went back toENOTTY, and the branch was rebased onto6286d36449; the 50 focused tests below pass there.guest_sce_netaborts at the first new check, withENOTTY. With the version that threw, it aborts onFIOCLEX.ctestover 36 socket,fcntl,polland libSceNet test executables (50 tests): 49 passed;guest_socket_options_multicastskips without a network.6286d36449,guest_sce_netneeds a standard input that is not a pipe. Since #19824, itsselectcheck on descriptors 0 to 2 fails withEBADFwhen standard input is a pipe, onmaintoo. These runs use/dev/null.ctest(6138 tests,-j 12) on the first version of this branch: 6122 passed. Of the 16 failures:.gitdirectory, network access or a passwd entry for the user:conventions_git_errors,test_script_registration,web_library_assets,title_run,title_run_identity,guest_kernel_sys_login,guest_net_ctl,guest_getloginandguest_getlogin_no_session;agc_driverGPU cases. These fifteen also fail onmainin the same environment;guest_wtf_data_logfailed once under-j 12and passed 5 of 5 runs on its own. Neither it nor the libraries it links (libSceNKWebKit, libSceJsc, libc) callssceNetIoctl.python3 tools/check_conventions.py --base origin/main: passed.python3 tools/pr_overlap.py --branchfailed closed on #5836, #12682, #12688, #12700 and #12965, which conflict withmain. None of their diffs changessceNetIoctl.libSceNet/Export.cppandGuestSceNet.cpp, and with #22395, which changes libkernel'sioctl.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-18T16:17:34Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
a5d48dbc39:tools/check_conventions.pypassed.guest_sce_net_testsbuilt cleanly.guest_sce_net,guest_net_inet_pton_source_faults):core/libs/prx/libSceNet/Export.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-18T16:34:37Z.
Review: APPROVED
Reviewed — looks good
Nothing in the inspected changes shows a concrete defect; the review is limited to the three changed files listed below, and no checks were run.
What I ran
Exact head:
a5d48dbc3951933fb37505603b12845d65bec0d9. No commands or tests were run. Read the prepared description, commits, manifest, and diff, then read all three changed files throughrepo_read.pyat the pinned head. The author reports test runs in the PR description; they were not run by this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests or builds were run. Windows, macOS, and console behavior were not verified. No changed files were excluded; all three changed files were read.
To get this to a good state
Nothing is required.