Repository navigation
fix(libkernel): reject empty ioctl requests and answer INET socket requests as measured on a PS5 - #11219
Conversation
…quests as measured on a PS5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed exact head 250ab52ce8eff60d4ed11c797345e5aa85240522 and the linked firmware 13.60 probe source/log. The 0x8000667f zero-length input request returns ENOTTY for the measured file, datagram socket, both pipe ends and directory, with null and non-null arguments. TIOCGWINSZ (0x40087468) on the measured AF_INET datagram socket returns EADDRNOTAVAIL; the other captured descriptor kinds return ENOTTY. The implementation applies the empty-length rule before descriptor argument handling and uses the measured ioctl group plus socket family to select the network error. The focused test updates cover the socket, file and pipe cases described in the PR.
Local git diff --check passed. Current-main conventions report no errors (one debt-length warning on the updated entry). I inspected the changed dispatch and tests, but did not run the kernel tests locally: the available build-review configuration is relinker-only and has no GuestKernelFcntl target. The PR reports 109 matching Windows tests passing three times; hosted product build jobs are skipped by path policy. Pairwise merge previews show the expected GuestKernelFcntl.cpp/debt overlap with #11135 and Udp.cpp overlap with #9713; please keep the stated dependency order when landing.
|
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.
|
|
@Ragbie @DavidSamir the overlap check lists your PRs against this one, and I compared the diffs by hand:
The behaviours are independent, so I propose yours land first and I refresh this PR after each of them, keeping your |
|
Windows and Linux runs of head
AI-assisted: yes (Claude Code); results above were run on this machine. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@slopgobblercobbler #12646 and this PR both change the socket |
|
@orezraey #13695 makes Proposed order: this PR first, since it's approved and merges cleanly into |
|
@Retr0G28 Yes, that order works: this PR first, then #13695. I merged both heads locally and only the |
|
Works for me: #11219 lands before #13695. A merge of the two heads conflicts only in the |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
The head 397c39f changes two ioctl paths and their tests; the source reads consistently with its tests, but the firmware-probe evidence cited by the earlier approval uses a request code that differs from the one in this head's test, and the console claims are not verifiable here, so I withhold approval.
What I ran
- Exact head:
397c39fce0f97a36d834dd2be79b725d43b661e2. Base:3498905cc00bd27d8e49ab908ab02c589846c9bb. Earlier approved head:250ab52ce8eff60d4ed11c797345e5aa85240522(its approval text was read; its diff was not compared line by line). - No build, no C++ compile, no test binaries. Source reads and helper runs only.
- Commands:
python3 -I tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 11219 --output-dir <scratch>/precheck/11219
python3 -I /marc/AnyPS5/tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 3498905cc00bd27d8e49ab908ab02c589846c9bb --head 397c39fce0f97a36d834dd2be79b725d43b661e2 --json
python3 -I /marc/AnyPS5/tools/pr_test_quality.py --root <git-archive extract of head core/ and tools/> --json core/libs/tests/GuestKernelFcntl.cpp
git grep -n -i "0x8000667f|0x80006601" 397c39fce0f97a36d834dd2be79b725d43b661e2 -- core tools docs
- Hosted check runs at this head: 8 completed with success, 6 skipped (none failing or pending at the time of review).
Results
| Check | Result | Notes |
|---|---|---|
git diff --check (base..head) |
passed | precheck |
| conventions and PR template | passed | precheck |
| live dependency and mergeability | passed | precheck |
| ABI audit (lexical, by helper) | 36 symbols, 0 findings | run by hand; the precheck entry failed only because the helper is not in the PR tree |
| test-quality heuristic (by helper) | 1 flag, false positive | possible-unregistered-cpp-test for GuestKernelFcntl.cpp; the file is registered at core/libs/prx/libkernel/CMakeLists.txt:2027 |
| C++ build and tests | not run | no build in this review |
| request-code lookup | 0x80006601 only | the tree has no 0x8000667f (see Findings) |
Unedited precheck output (conventions)
All conventions checks passed.
Negative control
Not run: the changed tests are C++ and need a build, which this review does not do. The new assertions are checked against the source only.
Findings
Blocking: none.
Non-blocking:
- The approval at
250ab52ce8says the firmware probe measured the zero-length input request0x8000667freturningENOTTY. At this head the test usesEmptyInputRequest = 0x80006601(core/libs/tests/GuestKernelFcntl.cpp:69), and0x8000667fdoes not appear anywhere incore,toolsordocs. Either the probe or the test is using a different code. Please state which request the probe measured and make the test use it, or explain the difference. - The
IoctlRequestMalformedchange (core/libs/prx/libkernel/File/src/DescriptorControl.cpp:553) now treats a zero-lengthRequestInrequest as malformed, not onlyRequestOut. That matches the new expectations in the test, but it is a behaviour change for every IN ioctl, so the firmware evidence needs to cover IN requests other than the one probed. - The
EADDRNOTAVAIL(49) branch for other groups on AF_INET and AF_INET6 sockets (core/libs/prx/libkernel/Socket/src/Udp.cpp:1487-1491) is supported only by the console log cited in the earlier approval; the reason for the group listi,r,fis not explained in this diff.
Sources
- Changed ioctl malformed check:
AnyPS5/core/libs/prx/libkernel/File/src/DescriptorControl.cpp
Lines 550 to 556 in 397c39f
- Socket branch:
AnyPS5/core/libs/prx/libkernel/Socket/src/Udp.cpp
Lines 1484 to 1492 in 397c39f
- Test constant and the zero-length assertion:
and
AnyPS5/core/libs/tests/GuestKernelFcntl.cpp
Lines 202 to 204 in 397c39f
- Test registration:
AnyPS5/core/libs/prx/libkernel/CMakeLists.txt
Line 2027 in 397c39f
Not verified
- Every PS5 firmware 13.60 claim, the probe source and log, and the measured errno values: not reproduced here.
- The C++ changes and the GuestKernelFcntl test run: not built, not run.
- Hosted check runs: completed at the time of review; their content was not read beyond the status counts.
To get this to a good state
- Confirm the request code the probe measured (
0x8000667for0x80006601) and align the test and the evidence with it. - Say in the commit body or the debt note which IN requests the firmware probe covers, since the malformed check now applies to all of them.
- No code change is requested beyond that; the approval can follow once the evidence and the test agree.
The pioctl0 probe measured _IOC(IOC_IN, 'f', 127, 0), 0x8000667f, on a file, a datagram socket, both pipe ends and a directory. The test used 0x80006601, which the probe never sent, so it now uses the measured code. That is the only empty input request measured. The malformed check applies to every other one because FreeBSD's sys_ioctl tests only the direction bits and the length, which the debt entry now says, along with why the i, r and f groups keep ENOTTY on an INET socket. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The probe measured |
✅ AMD GPU test: passedPR head
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (9, not counted against this PR)Validation IDs already present on main (5 IDs in 552 tests)Skipped (55)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@BunnyFl the overlap check lists #15556 against this PR on |
|
@orezraey agreed: #15556 first, then you refresh this one. Thanks for checking the merge. One update that makes the refresh easier. #15556 no longer rewrites the |
✅ AMD GPU test: passedPR head
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (7, not counted against this PR)Validation IDs already present on main (4 IDs in 624 tests)Skipped (59)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
|
@Retr0G28 #15890 and this PR meet only in |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ AMD GPU test: passedPR head
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (8, not counted against this PR)Validated but not compared (3, not in the main baseline's validation pass)Validation IDs already present on main (4 IDs in 646 tests)Skipped (65)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
ioctlnow rejects an input or output request with length 0 as malformed (ENOTTY) on every descriptor. It also answers an unknown request on anAF_INETorAF_INET6socket withEADDRNOTAVAILwhen the request group is noti,rorf. A retail PS5 (firmware 13.60) does both. Measured with a homebrew probe from a payload process; the source and console log are in this gist (pioctl0).On the console:
Empty input request.
_IOC(IOC_IN, 'f', 127, 0)(0x8000667f) fails withENOTTY(25) on a file, a datagram socket, both pipe ends and a directory, with a null argument and with a pointer. FreeBSD'ssys_ioctlrejects such a request only when the kernel is built without the 4.3BSD/FreeBSD 4–5 compatibility options. The debt entry said which of these the PS5 kernel has was unknown.0x8000667fis the only empty input request the probe sent, and the test uses it. The check covers every other one by inference:sys_ioctltests only the direction bits and the length, not the request code. On the datagram socket this request gaveENOTTY, where the measuredTIOCGWINSZgaveEADDRNOTAVAIL; on the other descriptorsENOTTYalone would not tell the check apart from an unknown request.EFAULT.TIOCGWINSZon anAF_INETdatagram socket givesEADDRNOTAVAIL(49), where files, pipes and directories giveENOTTY. That is FreeBSD'ssoo_ioctlpassing a request outside theiandrgroups toin_control, which fails without an interface. AnyPS5 returnedENOTTY.i,randfother thanFIONBIOandFIONREAD, and non-INET sockets, keep returningENOTTY, since they were not measured. FreeBSD'ssoo_ioctlsends groupsiandrtoifioctlandrtioctlinstead ofin_control;fhas no such branch there, so keepingENOTTYfor it is a choice for lack of a measurement.Already matching:
FIONREAD(file 5 bytes past the offset, socket 0, pipe read end 3, write end 0);FIONBIO, which togglesO_NONBLOCKinF_GETFL;TIOCGWINSZon non-sockets.Still different.
FIONREADon a directory returns 65536 on the console and still throws here, because that number comes from the console's file system. The debt entry now starts with that gap.tcsetsidon anAF_INETsocket. feat(libkernel_sys): implement scePthreadMutexIsowned, utrace and tcsetsid #9713 issuesTIOCSCTTY(0x20007461, groupt) through thisioctland testedENOTTYon a UDP socket, which came from the old catch-all rather than a measurement. FreeBSD'ssys_ioctlandsoo_ioctldo not look at the direction, so that request takes the path measured forTIOCGWINSZ(also groupt):guest_kernel_sysnow expectsEADDRNOTAVAILthere, and thelibkernel_sysdebt entry says so.TIOCSCTTYitself was not measured. A null argument on a void request still does not giveEFAULT, as feat(libkernel_sys): implement scePthreadMutexIsowned, utrace and tcsetsid #9713 intended.Before and after
ioctlENOTTYENOTTYENOTTYEFAULTENOTTYTIOCGWINSZon anAF_INETsocketEADDRNOTAVAIL(49)ENOTTYEADDRNOTAVAILFIONREAD,FIONBIO,TIOCGWINSZon non-socketsFIONREADon a directoryTested
2e5675adfa:maine772fb25ccwas merged in, with fix(libkernel): return EFAULT from socket ioctl for invalid memory pointers #12646. Inguest_kernel_fcntlthe socket case keeps this PR's empty input request (ENOTTY) andTIOCGWINSZ(EADDRNOTAVAIL) checks, followed by fix(libkernel): return EFAULT from socket ioctl for invalid memory pointers #12646's eightEFAULTchecks forFIONBIOandFIONREADthroughioctland_ioctl.guest_kernel_fcntl,guest_tcp,guest_udpandguest_kernel_syspass three runs in a row on Windows (MinGW, GCC 15.2) and on Linux (WSL, GCC);check_conventionspasses.125a0d5c55:main3d5a2a5cddwas merged in, with feat(libkernel_sys): implement scePthreadMutexIsowned, utrace and tcsetsid #9713.Udp.cppkeeps feat(libkernel_sys): implement scePthreadMutexIsowned, utrace and tcsetsid #9713's null-argument check and this PR's request check.guest_kernel_fcntl,guest_tcp,guest_udpandguest_kernel_syspass three runs in a row on Windows (MinGW, GCC 15.2) and on Linux (WSL, GCC);check_conventionspasses.cf7da83495:mainwas merged in, with fix(libkernel): set and clear close-on-exec with FIOCLEX and FIONCLEX on a socket #13695. Only theioctldebt entry met: it keeps this PR's wording and now listsFIOCLEXandFIONCLEXas handled on a socket.guest_kernel_fcntl,guest_tcpandguest_udppass three runs in a row on Windows (MinGW, GCC 15.2) and on Linux (WSL, GCC);check_conventionspasses.Windows 11, WinLibs GCC 15.2, full build. The 109 tests matching
fcntl|ioctl|socket|directory|pipepass 3 times out of 3.guest_kernel_fcntlnow checks:ENOTTYon a socket (null argument), a file (null and pointer) and a pipe;TIOCGWINSZgivesEADDRNOTAVAILon anAF_INETsocket.After merging
main3498905cc0with #10767 (head397c39fce0):guest_kernel_fcntlandguest_kqueuepass 3 times out of 3 on Windows 11 (WinLibs GCC 15.2) and 3 times out of 3 on Linux (WSL Ubuntu, GCC).tools/check_conventions.pypasses.At head
896bb41323:guest_kernel_fcntlandguest_kqueuepass 3 times out of 3 on Windows 11 (WinLibs GCC 15.2) and 3 times out of 3 on Linux (WSL Ubuntu, GCC). With the malformed check put back to output requests only,guest_kernel_fcntlfails on Windows.tools/check_conventions.pypasses.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)ioctl, _ioctldebt entry); fix(libkernel): check the module load and unload arguments as firmware 13.42 does #15556 (BunnyFl) adds a sysmoduleflagsdebt entry next to thetcsetsidone; merge order only. fix(libkernel): report a socket shut for reading in poll and select and wake their waiters #11223, fix(libkernel): return EFAULT from socket ioctl for invalid memory pointers #12646 and fix(libkernel): pass ioctl on a sceNetSocket socket to libSceNet #15890 have merged