Repository navigation
[net] close the listening socket on setup failure and open sockets CLOEXEC - #349
Open
ManoharPaturi wants to merge 1 commit into
Open
ManoharPaturi wants to merge 1 commit into
ManoharPaturi wants to merge 1 commit into
Conversation
…OEXEC getRecvSocket() leaked the freshly created listening socket when fcntl(O_NONBLOCK) or setsockopt(SO_REUSEADDR) failed. The listening socket was also created without SOCK_CLOEXEC and accepted connections without SOCK_CLOEXEC, so both stayed open across any execve() in the supervisor process.
ManoharPaturi
force-pushed
the
pr-net-sockhygiene
branch
from
September 27, 2026 08:58
fe64446 to
b13c456
Compare
Author
|
Small branch hygiene fix: my local CI workflow file accidentally ended up in this branch — force-pushed the branch rebuilt from current master with only the intended change. The diff is now just the patch itself; the actions scan failure from earlier is gone. |
Author
|
@robertswiecki Could you review this when convenient? It addresses two descriptor issues in |
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.
Problem
Two descriptor issues in
getRecvSocket():fcntl(O_NONBLOCK)orsetsockopt(SO_REUSEADDR)fails after the socket is created, the function returns-1without closing the socket — the fd leaks for the lifetime of the supervisor. In--mode listenwith--max_connsretry loops this accumulates.SOCK_CLOEXEC, andacceptConn()accepted connections withoutSOCK_CLOEXECas well, so both survive anyexecve()in the supervisor process (e.g. the newuidmap/newgidmap helper exec path insubproc::systemExe(), which has no fd sweep of its own).Change
close(sockfd)before the errorreturns after socket creation.SOCK_CLOEXECon thesocket()creation and on theaccept4()flags.Testing
Built and ran the full test suite (unit + cmdline) plus an ASan/UBSan build on Ubuntu 24.04 — all green, no new findings.