Skip to content

fix(libkernel): keep socket descriptors within FD_SETSIZE - #8595

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
MarcZX10:codex/socket-fdset-limit-followup
Oct 20, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
MarcZX10:codex/socket-fdset-limit-followup

Conversation

@MarcZX10

@MarcZX10 MarcZX10 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What

Follow-up to merged #4391. Guest socket descriptors are stored in the same descriptor table used by the guest fd_set, which has 1024 entries. ReserveNumber and the duplicate paths currently accept host descriptor numbers at or above 1024 when the table is under pressure. This change caps socket reservation, dup/fcntl duplication (including the minimum-descriptor form from #7437), and dup2 at 1024. Any temporary host descriptor above the limit is closed and the operation returns EMFILE.

The regression fills descriptors up to 1024, then checks that dup, F_DUPFD, F_DUPFD_CLOEXEC, socket creation, and dup2 to descriptor 1024 fail with EMFILE. The fcntl checks cover both minimum descriptor 0 and the 1024 boundary.

Tested

  • Current main 892a4f1328a14a123eca4af8f3c9ea5d176133ab: GCC C++20 syntax checks pass for Udp.cpp and the updated GuestSocketDescriptors.cpp.
  • git diff --check passes.
  • python3 tools/check_conventions.py --base upstream/main --head HEAD passes.
  • The focused guest_socket_descriptors CTest was attempted from the existing Linux build. The executable aborts during the global host CPU check, before entering the test body: this Xeon E5-1620 v2 lacks LZCNT, BMI1/2, MOVBE, AVX2 and FMA. The runtime assertions have not run on this host.

Checklist

@github-actions

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 5021 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 6044 core/libs/tests/GuestSocketDescriptors.cpp
PR 6977 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7088 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7201 core/libs/prx/libkernel/Socket/src/Udp.cpp

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Manual overlap check with #6044: that PR moves GuestSocketDescriptors.cpp to core/libs/tests/networking/GuestSocketDescriptors.cpp; it does not change Udp.cpp. There is no implementation dependency, but the test edit needs to be carried to the moved path if #6044 merges first. Since #6044 is currently dirty against main and has requested changes, would you prefer #8595 to land first, or should I rebase the test onto the moved file after your PR? I left Depends on: none because the code does not require #6044.

@oneandonlydean
oneandonlydean merged commit a6a4101 into boykopovar:main Oct 20, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants