fix(libkernel): support socket fcntl duplication #7437
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7437"
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 Queuse on 2026-10-18T06:22:09Z.
What
F_DUPFD,F_DUPFD_CLOEXEC,F_DUP2FD, andF_DUP2FD_CLOEXECfor guest socket descriptors with the lowest-free-descriptor and close-on-exec semantics used by FreeBSD 11.4.sceKernelFcntlvariadic argument to the guest-socket path, including pointer arguments for unsupported lock commands, and preserve descriptor metadata when an exact-target duplicate replaces another descriptor type.Tested
maine80325a4c7; headb6b1255830.cmake --build build --target libkernel guest_socket_descriptor_flags_tests guest_kernel_fcntl_tests guest_dup_tests guest_socket_descriptors_tests guest_udp_tests guest_tcp_tests --parallel 4passed after initializing the new upstream mimalloc submodule withgit submodule update --init --recursive.ctest --test-dir build -R '^(guest_socket_descriptor_flags|guest_kernel_fcntl|guest_dup|guest_socket_descriptors|guest_udp|guest_tcp)$' --output-on-failurepassed 6/6.guest_kernel_fcntlincludes host-socket checks from #7403.python tools/check_conventions.py --base origin/main: 0 errors, 1 debt-length warning on the existing long fcntl entry.git diff --check origin/main...HEAD: passed. Conflict-marker, UTF-8 BOM and machine-specific absolute-path checks passed.python tools/pr_overlap.py --branch fix/libkernel-socket-fcntl-duplication --repo boykopovar/AnyPS5: completed; findings and comparison limitations described above.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 github-actions[bot] on 2026-10-18T06:28:45Z.
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.
docs/dev/debt/libkernel.mdcore/libs/prx/libkernel/File/src/Open.cppcore/libs/prx/libkernel/Socket/src/Udp.cppdocs/dev/debt/libkernel.mdcore/libs/tests/GuestKernelFcntl.cppcore/libs/tests/GuestSocketDescriptorFlags.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/File/src/Open.cppdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Socket/src/Udp.cppcore/libs/tests/GuestKernelFcntl.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Socket/src/Udp.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/File/src/Open.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/File/src/Open.cppcore/libs/prx/libkernel/Socket/src/Udp.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/File/src/Open.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-18T10:09:46Z.
Review: COMMENTED
Linux run, since the description lists only Windows.
Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release,
BUILD_TESTING=ON, full build.Head
d35db7be1merged ontomain9caecfd2d(clean merge).guest_kernel_fcntlandguest_socket_descriptor_flagspass, as do the other fcntl/socket/dup tests (ctest -R "fcntl|socket|dup|udp|tcp", 19 tests).main:guest_socket_descriptor_flagsfails atF_DUPFD must honor the minimum and clear FD_CLOEXEC (errno 22);guest_kernel_fcntlaborts atsceKernelFcntl(socket, GetDescriptorFlags) == 1right aftersceKernelFcntl(socket, SetDescriptorFlags, 1)(I numbered theRequirecalls to find it): onmainonlyF_SETFLforwards its argument for a socket, which is theOpen.cppchange.ctest -E "^agc|gpu|vulkan|video_out"): 712/712, same asmain.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by Queuse on 2026-10-18T14:21:03Z.
Rebased this PR on current
main(a62c724c3; head5c624a139). Coordination check:Udp.cppbranches/declaration context; this PR changes platform-independent guest-socketF_DUP*semantics. No functional dependency found.Proposal:
Depends on: none; either PR may merge first, then any later PR rebases its nearbyUdp.cpp/debt context. Please flag a contrary dependency.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T18:54:56Z.
@lucaslima430 agreed, sorry for the slow reply. #7403 only changes the path for host sockets that aren't guest sockets, and this PR changes
F_DUP*on guest sockets. There's no dependency either way. The shared debt entry is a text conflict for whichever lands second, and I'll take it if #7403 is second.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by Queuse on 2026-10-18T21:26:50Z.
Rebased onto current
main(0d1c299a9; head335ce43d8). During the variadic forwarding review, I found thatsceKernelFcntlconsumed pointer arguments but did not pass them to the guest-socketfcntlpath, which then attempted to consume a missing argument. The new head forwards pointer arguments too and covers an unsupported lock command returningEINVALthrough the expected translated path.Windows targeted build and the six socket/fcntl/dup tests pass (6/6);
python3 tools/check_conventions.py --base origin/mainpasses; the current overlap scan reports #7403 only at the shared debt line, with no functional dependency as already agreed above. Linux was not rerun on this head; the earlier independent Linux result remains attached to its reviewed commit.AI-assisted: yes (Codex); implementation and test results were independently inspected in this session.
Imported from boykopovar/AnyPS5. Originally posted by Queuse on 2026-10-18T21:55:36Z.
Follow-up validation after the final rebase (
0bc3003f8->45e35c552):libkerneland the six focused test targets; CTest passed 6/6.python3 tools/check_conventions.py --base origin/mainpassed.git diff --check origin/main...HEADpassed.No machine-specific absolute paths were used in these reproduction instructions.
Imported from boykopovar/AnyPS5. Originally posted by Queuse on 2026-10-18T21:57:33Z.
Reviewed the newly reported overlap with #7509. It changes equeue pending-event bounds and a separate libkernel debt entry; it does not touch socket descriptor duplication behavior and creates no functional dependency. A context-only debt-file rebase may be needed for whichever PR lands second.
AI-assisted: yes (Codex); the patch was inspected directly.
Imported from boykopovar/AnyPS5. Originally posted by Queuse on 2026-10-18T22:04:01Z.
Final rebase update: current
mainis07377573fand this PR head is39101716f. The intervening main changes were AGC fixes plus libccopysignin an unrelated file. After rebasing, the Windows and WSL Ubuntu focused builds both completed and the six socket/fcntl/dup tests passed 6/6 on each platform. Conventions andgit diff --checkalso passed.AI-assisted: yes (Codex); all results above were rerun on the stated head.
Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T16:28:02Z.
First AMD-on-Linux (RADV) run of this PR. Merged onto
main0fbfd91e5(clean merge), built in full and compared with the samemain, on the same machine.AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release.
Full suite (
ANYPS5_REQUIRE_VULKAN=1 ctest -j8): 1637/1639 with this PR, against 1637/1639 onmain. The failures are the same two on both, so this PR adds none:agc_driver_image_table_vouched_lookups(#7766, fixed by #7916) andagc_driver_guest_memory_lifetime(#7784). The PR adds no new ctest entry, and no test is skipped or removed compared withmain.GPUs tested: n/a (libkernel change; suite run on the machine above)
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T15:44:37Z.
Rebased onto current
main(conflicts indocs/dev/debt/libkernel.mdandGuestKernelFcntl.cpp: keptmain'sioctlentry and new assertions next to this PR's close loop and fcntl entries). Thelibkernelandlibstests pass on the rebased head; the errno mapping change inOpen.cppand the rest of the interdiff look right. Merged.