fix(libkernel): fail ioctl on a ksem id with ENOTTY, as FreeBSD 11.4 does #24489
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24489"
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-20T17:29:01Z.
What
ioctlon a ksem id threw forFIONREAD,FIODTYPEand unknown requests, as the id is a host null device descriptor here, andFIONBIOandFIOASYNCchanged its status flags and returned 0. FreeBSD 11.4'sksem_opsanswers every request throughinvfo_ioctl, which fails withENOTTY, afterkern_ioctlhas handledFIOCLEXandFIONCLEXitself.FIONBIOandFIOASYNCleave the status flags alone, wherekern_ioctlsets them beforeinvfo_ioctlrefuses; the kqueue path does the same here. The debt entry says so.IsKsemDescriptor, which this uses, is replaced byDuplicateKsemDescriptorin open #22191. The two merge without a textual conflict, but whichever lands second needs a rebase that keeps a ksem predicate, or the build breaks. I will rebase this as soon as #22191 lands.IOC_INargument is still copied in first, assys_ioctldoes, so an unreadable or null one givesEFAULT.FIODTYPEline, which the new block makes unreachable, is removed.ControlsinGuestKernelSysKsem.cpp, through bothioctlexports, theEFAULTcases, andFIOCLEX/FIONCLEXchecked withF_GETFD.fix-libkernel-ioctl-fiodtype-character-device.mdsaid a ksem id still throws; it is edited in place.Tested
Linux (Debian 13, GCC 14.2.0, Release). Head
403f21f941, the single commit onmainc8f72e905c.main84e16538d4,guest_kernel_sys_ksemaborts withioctl: FIONREAD on a character device is not implemented.403f21f941,ctestoverguest_kernel_sys_ksem,guest_kqueue,guest_kernel_sys,guest_filesystem,guest_file_vector,guest_kernel_sys_aio,guest_equeue_events,guest_kernel_fcntl,guest_kernel_ioctl_fionreadandguest_kernel_ioctl_device_type: all 10 pass.ctest(6393 tests,-j 12) on this branch before review, which then added theIOC_INcopy-in and theEFAULTchecks, and my other eleven branches of this round, merged ontomain84e16538d4: 6378 passed. The 15 failures also fail onmainin this 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_driverGPU cases fail the same way onmain:prepared_shaderswith itsindirect,uncachedanddebugforms, andstorage_file_write;agc_driver_image_table_packed_guardsis unstable onmainas well (2 of 10 runs passed on its own onmain3f4693be43).python3 tools/check_conventions.py --base origin/main: passed.python3 tools/pr_overlap.py --branch fix/libkernel-ksem-ioctl-enotty: could not compare #7121, #9293, #9297, #9302, #9557, #9566, #12682, #12688, #12700, #12965 and #18457, which conflict withmain; none of them touches the ksem or kqueue lines ofIoctl.git merge-treewith my #22395 and #22396 is clean.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)Summary by CodeRabbit
Bug Fixes
ENOTTYerror.EFAULT, and supported requests preserve the semaphore’s value.Tests
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T17:51:22Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
403f21f941:tools/check_conventions.pypassed.guest_kernel_sys_ksem_testsbuilt cleanly.guest_kernel_sys_ksem):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
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T05:43:51Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the code read supports the requested ksem ioctl behavior, and the author reports passing targeted tests.
What I ran
Read the prepared diff and changed source files at head
403f21f941ea73658c27a96c1c8b73e70fcfe949usingrepo_read.py. I did not run commands or tests.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests or builds were run during this review. The description reports 10 targeted tests and a conventions check passing, but these results were not independently verified. Read:
core/libs/prx/libkernel/File/src/DescriptorControl.cpp,core/libs/tests/GuestKernelSysKsem.cpp, anddocs/dev/debt/changes/fix-libkernel-ioctl-fiodtype-character-device.md. Excluded files: none listed in the supplied manifest;files.jsonwas unavailable through the reader.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T13:10:01Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation and tests support the stated ksem
ioctlbehavior.What I ran
Reviewed head
e1e2c04182cfedebab54d9c2af55f12bd904ceb1using the prepared diff and the pinned repository reader. No commands or tests were run;repo_read.pywas not invoked.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run in this review. Build and runtime behavior on Windows and macOS were not verified. No files were excluded from the prepared diff; all changed files listed in
manifest.jsonwere read. The description's test claims were not independently verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T14:08:50Z.
Review: APPROVED
I read the diff at
e1e2c04182. Windows 11 with GCC 15.2 and Linux (Ubuntu 24.04 in WSL2, GCC 13.3), merged intomainat6c6b29320fetogether with other open PRs (so not an isolated build).guest_kernel_sys_ksem: pass on both.main's, the same test fails too.Not checked: a console.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T14:25:20Z.
Review: COMMENTED
Built and ran
guest_kernel_sys_ksemon Linux with this head integrated. The suite passed. It coversENOTTYfor unsupported semaphore controls, the pointer-error cases, and the descriptor flags that remain usable on a semaphore descriptor.AI-assisted: yes.