Repository navigation
Conversation
… descriptor is looked at FreeBSD's sys_ioctl rejects a request with no direction bit, an output request with no length, or a void request whose length is not an int before it reads the argument or resolves the descriptor. ioctl threw on such a request for a file, pipe or directory, failed with EBADF for a closed descriptor and with EFAULT for a socket given no argument. (cherry picked from commit 501518f) (cherry picked from commit 3eb7edd)
…t boundaries The OpenOrbis net_http sample stops on 0x5413, the Linux TIOCGWINSZ that musl sends to standard output; the carried cases covered 0x5401 but not that word, so the test adds it to the malformed words. It also pins the two boundary words the check takes as well-formed, 0x20046601 (IOC_VOID, length 4) and 0x80006601 (IOC_IN, length 0): on a guest socket with a null argument they fail with EFAULT, not ENOTTY. The debt sentence now states the open gap: an input request with length 0 is not rejected as malformed, while sys_ioctl rejects it in a kernel built without COMPAT_FREEBSD4, COMPAT_FREEBSD5 and COMPAT_43, and which of these the PS5 kernel has is unknown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
MarcZX10
reviewed
Oct 19, 2026
MarcZX10
left a comment
Contributor
There was a problem hiding this comment.
Manual overlap check against #7437:
- The implementation changes are separate: #7437 adds socket
fcntlduplication commands, while this PR rejects malformedioctlrequests. InUdp.cpp, they modify thefcntl_nid_postfixandioctl_nid_postfixpaths respectively. - Both PRs add assertions in
GuestKernelFcntl.cpp's socket coverage and update adjacent entries indocs/dev/debt/libkernel.md, but they cover different behavior. I found no duplicate implementation or dependency. When rebasing/merging, retain both test additions and both debt updates.
12 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
On
main,ioctland_ioctlthrow when a file, pipe or character device gets a request word that FreeBSD'ssys_ioctlrejects as malformed, unless the word is in the termios groupt(such a word already fails there withENOTTY); a closed descriptor fails withEBADFinstead ofENOTTY, and a guest socket given a null argument withEFAULT. The OpenOrbis PS4 toolchain'snet_httpsample stops there: its musl sends the LinuxTIOCGWINSZ(0x5413, no direction bit) to standard output on the firstprintf, and the run ends with@Get-fix reported this on Windows 11 in #5564; with #5569 the sample ran its whole flow. #3093 tracks it as
[ ] Linux terminal ioctl 0x5413 (#5564, #5569), and its later updates (1, 2) count a change that answers the LinuxTIOCGWINSZwithENOTTYamong the changes that let 14, then 15, of the 16 samples start on Windows. The other changes listed there (#5990 to #5994, #6376, #5138) are merged, and Get-fix's open #6519, #6520 and #6521 were tested with such a change too. On Linux,main'slibkernel.prxthrows the same line forioctl(1, 0x5413, buffer)when standard output is redirected to a file (probe under Tested).This carries @husseinkad's commit from #5569 (opened by @MarcZX10), with his authorship kept (
git cherry-pick -x 3eb7edd9cf). #5569 was closed with "Closing: no title is known to reach this. [...] If a title stops on this on current main, reopen with the title ID and the log line." The log line is above; I can't reopen #5569, so this is a new pull request. Its two conflicts with currentmainare resolved without changing its code: the test keepsmain'sCloseOnExecRequestandKeepOnExecRequestnext toMalformedRequests, and the debt entry keepsmain'sFIOCLEXwording with the commit's sentence added.Reference: FreeBSD 11.4
sys_ioctltruncates the request to 32 bits and returnsENOTTYif it has none ofIOC_VOID,IOC_INandIOC_OUT, if it hasIOC_OUTand length 0, or if it hasIOC_VOIDand a length that is neither 0 norsizeof(int)(encoding). That comes before the argument'scopyinand beforekern_ioctllooks up the descriptor, so it wins overEFAULTandEBADF. TheIOC_OUTtest is the branch built with any ofCOMPAT_FREEBSD4,COMPAT_FREEBSD5andCOMPAT_43, and amd64GENERIChas the first two; without them,IOC_INwith length 0 fails as well.File::IoctlRequestMalformedapplies those three tests.File::Ioctlchecks it first, andioctl_nid_postfixchecks it for a guest socket before the lookup and the null-argumentEFAULT, so every descriptor kind, a closed one included, fails withENOTTY.IOC_VOID, length 4) and 0x80006601 (IOC_IN, length 0) given to a guest socket with a null argument fail withEFAULT, notENOTTY. It also rewrites the carried debt sentence as the open gap: an input request with length 0 is not rejected as malformed, and which of the COMPAT options the PS5 kernel has is unknown.Differences from the reference: an
IOC_INrequest with length 0 is still treated as well-formed, as in a kernel with those COMPAT options; whether the PS5 kernel has them is unknown, asdocs/dev/debt/libkernel.mdrecords. Not measured on a console.Tested
BUILD_TESTING=ONon upstreammain43a2abaf7.guest_kernel_fcntl(core/libs/tests/GuestKernelFcntl.cpp) sends 0, 123, 0x5401, 0x5413, 0x40007468, 0x20087468 and 0x00087468, each with a buffer and with a null argument, to an open UDP socket, an open file, the same file afterclose, descriptor -1 and a pipe, and requires -1 withENOTTY. It also sends 0x20046601 and 0x80006601 with a null argument to the socket and requires -1 withEFAULT. Its existing checks ofFIOCLEX,FIONCLEX,FIONBIO,FIONREAD, the BSDTIOCGWINSZ(ENOTTY) andFIOASYNC(throws) are unchanged. It passed 3 runs in a row.DescriptorControl.cpp,DescriptorControl.hppandUdp.cppfrommain,guest_kernel_fcntlaborts at its first null-argument call on the socket,ioctl(socket, 0, nullptr), which fails withEFAULT(guest errno 14 at the abort, under gdb). With onlyUdp.cppfrommainit aborts at the same call. With all three frommain, a scratch copy of the test that runs one section per process shows the file and pipe sections ending withterminate called after throwing an instance of 'std::runtime_error'andwhat(): ioctl: request 0x00000000 on a file is not implemented, fd=5(on a pipefor the pipe).DescriptorControl.hpporDescriptorControl.cppalone frommaindoes not build, sinceUdp.cppthen calls an undeclared or undefined function. The 0x20046601 and 0x80006601 checks on the socket have no negative control, since they pass onmaintoo: run alone in the same scratch copy with all three files frommain, they pass.libkernel.prx, with standard input from/dev/null(a character device): onmain,ioctl(1, 0x5413, buffer)with standard output redirected to a file throwsioctl: request 0x00005413 on a file is not implemented, fd=1; 0x5413, 0x5401 and 0 throw on a file, a pipe and the character device, while 0x40007468, 0x20087468 and 0x00087468 (groupt) fail there withENOTTY; descriptor 4000 fails withEBADF, and a UDP socket with a null argument fails withEFAULT. With this change all of these,_ioctl, and 0x5413 with the upper 32 bits set fail withENOTTY, while 0x20046601 (void, length 4) and 0x80006601 (in, length 0) still throw on a file, asFIOASYNCwith a buffer does, and on a socket with a null argument they andFIONREADfail withEFAULT, as onmain.tools/select_tests.pypicked 1349 of 1638 tests for this diff: 1334 passed, 0 failed, 15 skipped (the 13video_out_flip_*tests andvideo_out_frame_dump_queuereportno display or Vulkan device, as SDL's offscreen driver has no Vulkan here;agc_driver_stencil_ref_exportreports that the device lacksVK_EXT_shader_stencil_export).guest_udp,guest_sendfileandguest_sce_netare among the passed.x86_64-w64-mingw32-g++16.2.0-fsyntax-only -Wall -Wextraon the three changed.cppfiles: no errors or warnings, as for theirmainversions. This is a syntax check, not a Windows build or run.tools/check_compile.py --base upstream/main: 3 translation units compile.tools/check_conventions.py --base upstream/mainwith this title and body: 0 errors, 1 warning (debt-lengthon theioctlentry, 1649 characters; it is 1297 onmain, already over the 1000 the warning allows).tools/pr_overlap.py --branchlists fix(libkernel): support socket fcntl duplication #7437 (socketfcntlduplication), which changes neighbouring lines ofGuestKernelFcntl.cppand the next debt entry; it implements other commands, so whichever of the two is merged second needs only a textual rebase. It could not compare the open PRs that conflict withmain; merged with this branch, feat(aot): consolidate native ARM64 compiler, runtime and consumers #5021, feat: run PS4 games on the AGC driver — Limbo (CUSA01664) plays at 60 fps #6977 and Macos port #7201 conflict in the same files as they do withmain, and feat: macOS on Apple Silicon host support (Rosetta 2 and MoltenVK) #7332 merges cleanly.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)🤖 Generated with Claude Code