fix(libkernel): fail an ioctl request randomdev_ioctl does not handle with ENOTTY on the random device, as FreeBSD 11.4 does #22396
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22396"
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-17T14:05:28Z.
What
Builds on #22395, which this branch contains; review its last commit.
An
ioctlon/dev/randomor/dev/urandomthrew for any request without a case for every descriptor (other thanFIONREAD, which already fails withENOTTY). In FreeBSD 11.4,devfs_ioctl_f(sys/fs/devfs/devfs_vnops.c:763-779) answers onlyFIODTYPEandFIODGNAMEitself and hands the rest torandomdev_ioctl(sys/dev/random/randomdev.c:301-316). That function acceptsFIOASYNCandFIONBIOand refuses everything else withENOTTY, the owner requests included. Those requests now fail withENOTTY; the input argument is copied in first (#22395).FIODTYPEandFIODGNAMEstill throw, as they report the device's flags and name, which are not modelled for the console.GuestKernelIoctlFionread.cpp: on both devices, throughioctland_ioctl, the following fail withENOTTYand leave the argument unchanged:FIONWRITE,FIONSPACE,_IOW('x', 1, int),FIOSETOWNandFIOGETOWN;IOC_IN|IOC_VOIDrequest0xa0047801with a null argument.ioctl on the random deviceentry, with the two throwing requests first. The pending fragment of #22296 makes theioctl, _ioctlentry point toioctl on a pipe. Here it points to "theioctl onentries" instead, and "firmware" is dropped to keep it under 1000 characters (990).Tested
Linux (Debian 13, GCC 14.2.0, Release). Now rebased onto #22395's head
affff6f058(onmaineb4300802c); the only conflict wasmain's newFIONREADsentence in theioctl, _ioctlentry offix-libkernel-ioctl-pipe-unknown-request-enotty.md, which this branch points at theioctl onentries.check_conventionswarns that this entry, already 1,216 characters onmain, is over 1,000; this branch changes five words of it. The other runs below used this branch onmain9f94e4a2cewith #22395.Rebased onto
maindb68035f8b. There,eceaaa2a07adds the sameDeviceTypeRequestconstant and answersFIODTYPEon other character devices; on the random device it still throws, as its debt entry says. The conflict was only that constant, so this branch now addsDeviceNameRequestalone. After the rebase,ctestforguest_kernel_ioctl_fionread,guest_kernel_fcntl*,guest_kernel_pipe_bounds,guest_kernel_app_archive*,guest_kqueue*,guest_sce_net*,guest_sendfile,guest_udp*andguest_tcp: 22 passed. The libkernel debt fragments fold withtools/debt_fold.py --check.e67e86641e, merged with my eight other updated branches ontomainbd9a6c00a6:ctestover the 23 tests these branches touch (guest_kernel_ioctl_fionread,guest_kernel_ioctl_device_type,guest_kernel_fcntl*,guest_kernel_app_archive_*,guest_kernel_sys_ksem,guest_kqueue,guest_equeue_events,guest_socket_events,guest_system_configuration,guest_socket_pair,guest_recvmsg_memory,guest_kernel_sys_cpuset,np_uds_events,guest_np_uds_*andguest_np_trophy_*): all pass.ctest -R '^(guest_kernel_ioctl.*|guest_kernel_fcntl.*)$': 3 passed.ioctl: request 0x40046677 on a random device is not implemented.ctest(6006 tests,-j 12) on this branch and my other four branches of this round, merged ontomain1af270fa29: 5988 passed. All 18 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);patched_self_imports,guest_libressl3_ec_parametersandguest_libressl3_asn1fail onmain1af270fa29when run on their own.python3 tools/check_conventions.py --base origin/main: passed.python3 tools/pr_overlap.py --branchfailed closed on the same PRs as #22395. None changesioctlon the random device.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-17T14:08:09Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
770cf06642: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/include/DescriptorControl.hpp,core/libs/prx/libkernel/File/src/DescriptorControl.cpp,core/libs/prx/libkernel/Socket/src/Udp.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-23T03:48:30Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed implementation and focused tests support the stated random-device
ENOTTYbehavior.What I ran
Reviewed head
e3005a5c5a3b29ea5a3384b6e876852b10bf9d71using the prepared diff andrepo_read.py. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Did not run the reported test suite or inspect the full contents of every changed file. Read the prepared description, commits, manifest, diff,
DescriptorControl.cpplines 90–125 and 550–630,Udp.cpplines 2080–2145, andGuestKernelIoctlFionread.cpplines 1–48 and 390–465. All seven changed files are marked included in the manifest; the other changed files were not read in full. Windows, macOS, and console behavior were not verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T12:19:26Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation and added tests support the stated random-device ioctl behavior.
What I ran
Reviewed head
e67e86641e19756e44edabe3e17b33f7d494eb38using the prepared diff andrepo_read.pyfor changed-file context. No commands or tests were run by me; test results in the description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author-reported test runs and behavior on Windows, macOS, and physical console hardware were not independently verified. The prepared bundle lists no excluded changed files.
To get this to a good state
Nothing is required.