fix(libkernel): fail an ioctl request pipe_ioctl does not handle with ENOTTY on a pipe, as FreeBSD 11.4 does #22296
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22296"
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-17T11:20:31Z.
What
Builds on #22295, which this branch contains; review its last commit.
A well-formed
ioctlrequest on a pipe or FIFO that has no case for every descriptor (FIOCLEX,FIONCLEX,FIONBIO,FIONREAD,FIOASYNC, termios) threw. Examples areFIONWRITE,FIONSPACE,FIODTYPEand any request outside groupsfandt. In FreeBSD 11.4,kern_ioctlpasses such a request topipe_ioctl(sys/kern/sys_pipe.c:1346-1419), whosedefaultreturnsENOTTY, and a FIFO uses the same pipe operations (fifo_open,sys/fs/fifofs/fifo_vnops.c:252). On a pipe above descriptor 2, the request now fails withENOTTYand leaves its argument alone. An input argument is first copied in assys_ioctldoes, so an unreadable one fails withEFAULT. AnIOC_VOIDrequest passes its argument by value, so nothing is copied for it. The existing null-argument check inFile::Ioctlfollows that rule too; sockets keep their own check inUdp.cpp. So anIOC_IN|IOC_VOIDrequest with a null argument, which used to fail withEFAULT, now getsENOTTYon a pipe above descriptor 2, on a kqueue or for atgroup request, as on FreeBSD, and reaches the existing throw on a file (one read from app0.zar included), a directory, the random device or another device.Terminal.cppandpollalready treat them, so such requests still throw there.FIOSETOWNandFIOGETOWNstill throw on a pipe, since the pipe'sSIGIOowner is not kept here; #9557 and #9566 implement it.TIOCSPGRPandTIOCGPGRPkeep theENOTTYthat every termios request gets.GuestKernelIoctlFionread.cppchecks both ends of a pipe, through bothioctland_ioctl:FIONWRITE,FIONSPACE,FIODTYPEand_IOW('x', 1, int)fail withENOTTYand leave the argument unchanged;_IOW('x', 1, int)with an unreadable argument fails withEFAULT;FIONWRITEwith an unreadable argument still fails withENOTTY, since nothing is copied out on an error;IOC_IN|IOC_VOIDrequest0xa0047801fails withENOTTYwith a null and with an unreadable argument.ioctl on a pipeentry. It lists first what still differs from FreeBSD: the owner requests and descriptors 0 to 2. Theioctl, _ioctlentry's "any other well-formed request not listed here" now points to it; the entry stays under 1000 characters.Tested
Linux (Debian 13, GCC 14.2.0, Release), on
main47b33132f9with #22295.ctest -R '^(guest_kernel_ioctl.*|guest_kernel_fcntl.*)$': 3 passed.ioctl: request 0x40046677 on a pipe is not implemented.ctest(6000 tests,-j 12) on this branch and my other five branches of this round, merged ontomain47b33132f9: 5985 passed. All 15 failures also fail onmainin the same environment:.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_drivercases (agc_driver_image_table_packed_guardspasses when run on its own).python3 tools/check_conventions.py --base origin/main: passed.python3 tools/pr_overlap.py --branch:SetOwnerRequestandGetOwnerRequestconstants next to mine inDescriptorControl.cpp, so the two conflict textually.main; none returnsENOTTYfor other pipe requests.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-17T11:30:59Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
ec2bf019bb:tools/check_conventions.pypassed.guest_kernel_fcntl_tests,guest_kernel_ioctl_fionread_testsbuilt cleanly.guest_kernel_fcntl,guest_kernel_ioctl_fionread):core/libs/prx/libkernel/File/src/DescriptorControl.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me