libkernel: ioctl with a malformed request aborts the guest on files and pipes instead of returning ENOTTY; fix branch ready #5564
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 husseinkad on 2026-10-13T23:59:34Z.
ioctl(and_ioctl) with a malformed request throws "request ... is not implemented" on a file, directory, pipe,stdinorstdout, which ends the process, and returns the wrong error on other descriptors. FreeBSD 11.4sys_ioctlreturnsENOTTYfor a malformed request before it reads the argument or looks at the descriptor. "Malformed" means: no direction bit (IOC_VOID,IOC_INorIOC_OUT), an output request with length 0, or a void request with a length other than 4. A Linux request number such asTCGETS(0x5401) is malformed by that rule, so a guest or library that probes with it getsENOTTYon a console. Here the same call aborts the guest on a file or pipe, returnsEBADFon a closed descriptor, and returnsEFAULTon a socket given a null argument.Fix branch: https://github.com/husseinkad/AnyPS5/tree/fix/libkernel-ioctl-malformed-request (one commit on a recent main:
File/src/DescriptorControl.cppand.hppwith a newFile::IoctlRequestMalformedchecked first inFile::Ioctl, the socket path ofioctl_nid_postfixinUdp.cppcalling the same check, tests intests/GuestKernelFcntl.cpp, and a debt note indocs/dev/debt/libkernel.md).Checks:
guest_kernel_fcntlcases fail on main (abort) and pass with the change;guest_udpandguest_sendfilepass.stdin,stdoutand fd 4000, each with a null and a valid argument: 886,336 results per build. All 12,063 distinct malformed requests giveENOTTY(25) on every descriptor kind (main threw, or returnedEBADForEFAULT). All 7,602 distinct well-formed requests are unchanged: unknown ones still throw on files, sockets still giveENOTTYorEFAULTas before, andFIONBIO,FIONREADand every termios request behave identically. I computed about two dozen FreeBSD 11FIO*,TIOC*andSIOC*requests; none is classified as malformed, and only the deliberately bad probes are (0, 0x7b, 0x5401, 0x5413 and others).sys_ioctlconditions and its order (the malformed check before the argument copy and before the descriptor lookup).check_conventions.pyis clean andpr_overlap.pyfound only docs-line overlap with #4954, #5020 and #5053, which edit the sameioctlline indocs/dev/debt/libkernel.md(a one-line rebase).Not covered: an input-only request with length 0 is deliberately not rejected, because FreeBSD treats it differently with and without the compatibility options and the console's kernel configuration is unknown (recorded in the debt note).
FIOCLEXis claimed by #5186. There is nosceKernelIoctlexport in the repo. Only Windows was built and run.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T00:08:59Z.
I carried the ready malformed-ioctl change into PR #5569. Local
guest_kernel_fcntlandguest_sendfilepassed three consecutive runs each, and conventions/diff checks pass.guest_udpwas intermittent: it passed once, then aborted on repetition; restoring the current-mainUdp.cppreproduced the same pass-then-abort behavior, so I have not treated UDP as a reliable pass. The PR checks currently pass conventions, eligibility, intake, and report; platform jobs are skipped by path filters.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T01:07:52Z.
Closing: no title is known to reach this, and functions are only changed when a title needs them. #5569 is closed for the same reason. If a title stops on or misbehaves because of it on current main, comment here with the title ID and the log line.
Imported from boykopovar/AnyPS5. Originally posted by Get-fix on 2026-10-14T18:38:44Z.
@oneandonlydean A program that reaches this on current
main: the OpenOrbis PS4 toolchain samplenet_http. Its musl C library sends the LinuxTIOCGWINSZ(0x5413, no direction bits) to standard output on the firstprintf, and the run ends there:This was on Windows 11 with
maine442f4c2eplus #5990 to #5994, which the sample needs to start (#3093). The throw comes fromFile::Ioctlonmain, which those PRs don't change.With #5569 merged as well, the sample runs its whole flow.
sceNet,sceSslandsceHttpinitialize, and the sample prints its own report of the offline HTTP backend'sSCE_HTTP_ERROR_NETWORK(sceHttpCreateRequestWithURL (80431063)) instead of aborting.guest_kernel_fcntl,guest_udp,guest_sendfileandguest_sce_netpass in that build.#5569's head no longer merges cleanly into
main. I resolved its two conflicts locally to test it, and nothing else:GuestKernelFcntl.cppconstants: kept both sets;ioctlline indocs/dev/debt/libkernel.md: keptmain'sFIOCLEXwording and added #5569's malformed-request sentence.AI-assisted: yes (Claude Code). I ran the sample and the tests myself on Windows 11.
🤖 Generated with Claude Code