Repository navigation
fix(libkernel_sys): answer fpathconf on a socket as FreeBSD answers it for a pipe - #10427
Conversation
|
The Windows-specific change matches the helper's existing socket registry and the PR's stream/datagram coverage looks appropriate. I independently ran MinGW C++20 syntax checks on the changed One contribution-rule follow-up: the overlap report identifies a changed |
|
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.
|
harisibrar1
left a comment
There was a problem hiding this comment.
Checked against main 11d6efa and FreeBSD release/11.4.0 sys/kern/kern_descrip.c (identical to the 8c639945 copy linked in the description):
kern_fpathconf(L1400-1433) answers a descriptor withoutf_vnodethat isDTYPE_PIPEorDTYPE_SOCKETwithPIPE_BUFfor_PC_PIPE_BUFand EINVAL otherwise, so treating a guest socket like a pipe matches 11.4. On main, the Windows socket number is a NUL placeholder (ReserveNumberinUdp.cpp), which explains why_fstat64never reported a FIFO. The PR still merges cleanly onto current main.- Small gap, for this PR or a follow-up: a descriptor from
sceNetSocketis kept in libSceNet's own table (KernelReserveSocketNumber_nid_no_patch, libSceNetExport.cppL1021), not in theGuestSocketsmap thatGuestSocketIsOpen_nid_no_patchchecks. I couldn't run this, but reading the code suggests that on Windowsfpathconfon such a descriptor still returns the UFS constants (e.g._PC_LINK_MAX32767). Linux is fine, because there the number is a dup of the real socket.KernelFindSocketNative_nid_no_patchis the lookuppolluses for those. Otherwise the debt entry could say the guest-socket case covers onlysocket()descriptors on Windows.
Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
|
@harisibrar1 Thanks, that was a real gap. In a8a7d7e the Windows branch of
|
harisibrar1
left a comment
There was a problem hiding this comment.
Re-checked head a8a7d7e against main 6cd36e6:
- The fix is in:
_fpathconfon Windows now asksKernelLookupSocketNative_nid_no_patch(Export.cpp:397-399). That checks the samesocketsmap asGuestSocketIsOpenfirst, then falls back to libSceNet's registeredFindSocketNativeForKernel, so asceNetSocketdescriptor now gets_PC_PIPE_BUF512 / EINVAL too. - The helper is declared
extern "C"inSocketPoll.hppand defined in libkernel, which libkernel_sys already links; libSceSsl already calls it across modules the same way. - The
CMakeLists.txtchange only adds libSceNet toguest_kernel_sys_tests, andCheckSocketPathconfcovers stream and datagram sockets from bothsocket()andsceNetSocket. - The debt wording "for a pipe or a socket" now holds for both kinds, and it still merges cleanly onto current main. Thanks, LGTM.
Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
# Conflicts: # core/libs/prx/libkernel_sys/Export.cpp # core/libs/tests/GuestKernelSys.cpp
|
Merged |
|
Hi @Retr0G28, the overlap check shows my open PRs next to this one:
The changes are separate. Only the neighbouring lines overlap. Proposed merge order: this PR first, then #11031 and #11032, which I'll rebase onto it after it merges. I've recorded that under |
|
Tested head
A related gap, already on
In AI-assisted: yes (Claude Code); results above were run on this machine. |
# Conflicts: # docs/dev/debt/libkernel_sys.md
|
@Gruzzberry Agreed: this PR first, then #11031 and #11032. I've noted it in the description. @wachi35676 Thanks for the Linux run and the kqueue and Merged |
# Conflicts: # core/libs/CMakeLists.txt # core/libs/prx/libkernel_sys/Export.cpp # core/libs/tests/GuestKernelSys.cpp
|
Merged
The debt entry merged cleanly. Head fdeee74, Windows 11 (GCC 15.2.0): |
What
FreeBSD 11's
kern_fpathconfanswers a pipe and a socket the same way:_PC_ASYNC_IOgives 200112,_PC_PIPE_BUFgivesPIPE_BUF(512), and every other name fails withEINVAL.fpathconfand_fpathconfdid that for a pipe on every host and for a socket on Linux. On Windows,_fstat64of a guest socket's descriptor does not report_S_IFIFO, so a socket was answered with the UFS file constants:_PC_LINK_MAXgave 32767,_PC_NAME_MAX255, and so on.On Windows, a descriptor that
KernelLookupSocketNative_nid_no_patchfinds now takes the pipe path. libSceSsl already uses that lookup for a connection's socket. It covers the kernel's own sockets fromsocketandsocketpair, and through libSceNet's registered lookup, sockets fromsceNetSocketandsceNetAccept. libSceNet keeps those in its own table, and on Windows their number is the sameNULplaceholder. The debt entry says "for a pipe or a socket". Its clause that a guest socket fails thefstatcheck withEBADFis removed, as that is not what happens.Test: the pipe checks in
guest_kernel_sysmove intoCheckPipeBufferPathconf.CheckSocketPathconfruns them on anAF_INETstream socket and anAF_INETdatagram socket, from bothsocketandsceNetSocket, through bothfpathconfand_fpathconf.guest_kernel_sys_testsnow links libSceNet for this.Tested
Windows 11, WinLibs MinGW-w64 GCC 15.2.0 r7, CMake + Ninja, Release,
-DBUILD_TESTING=ON, onmaina23f8fc.main'sExport.cpp,guest_kernel_sysfails in the socket checks:Kernel sys check failed at line 435, the loop over names that must fail withEINVAL. With this PR it passes.Export.cpp(onlyGuestSocketIsOpen_nid_no_patch), thesceNetSocketchecks fail (exit 0xc0000409). With head a8a7d7e they pass.guest_kernel_sys,guest_net_buffer_validation,guest_sce_netand the 27guest_socket*tests pass on a8a7d7e.python tools/check_conventions.py --base origin/mainreports no errors.mainafc780e (head df9dd6a):guest_kernel_sys,guest_net_buffer_validation,guest_sce_netandguest_socket_pairpass.main3a2b919 (head fdeee74): the same four pass.main'sExport.cppthey still pass there, as theS_ISSOCKcheck already handled sockets. No title or homebrew run.Overlap (
tools/pr_overlap.py):EBADFclause.kenv) and fix(libkernel_sys): fail fpathconf on a kqueue or shm descriptor with EOPNOTSUPP #11296 (fpathconfon a kqueue orshmdescriptor) have merged.mainis merged here: theCMakeLists.txtlink line takes bothlibSceNetandlibSceAmpr, the test keeps both new check functions, and_fpathconfkeeps both the socket lookup and fix(libkernel_sys): fail fpathconf on a kqueue or shm descriptor with EOPNOTSUPP #11296'sEOPNOTSUPPbranch.getfsstat) changes lines next to this PR's test inGuestKernelSys.cpp. Agreed with its author: this PR goes first, and it declaresDepends on: #10427._fpathconf: feat(aot): consolidate native ARM64 compiler, runtime and consumers #5021, test: organize library tests and label CTest suites #6044, Macos port #7201, fix(libkernel_sys): validate descriptor first in fchown #8457, feat(libkernel_sys): export _openat #8701, feat(libkernel_sys): implement pwrite through the shared POSIX provider #9019, feat(libkernel_sys): implement sceKernelFlock over flock #9097, feat(libkernel_sys): implement statfs symlinkat and futimesat #9161, feat(libkernel_sys): implement POSIX message queues #9297, feat(libkernel_sys): implement kmq_notify registration #9302, fix(kernel): safely copy guest path arguments #9423, feat(libkernel_sys): implement lchflags #9442, feat(libkernel_sys): implement setlogin #9693, feat(prx): complete stubs across 30 system, audio, and utility libraries #9826, fix(libkernel): fchown, fstat and ioctl on a kqueue descriptor behave as FreeBSD #10016.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)