Repository navigation
nstun: drain TCP listener at flow capacity - #364
Open
elnadym165 wants to merge 1 commit into
Open
elnadym165 wants to merge 1 commit into
elnadym165 wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Summary
Fix an NSTUN TCP listener busy-loop condition when the aggregate TCP flow limit is reached.
Previously,
handle_host_tcp_accept()checked the IPv4/IPv6 TCP flow count before callingaccept4(). AtNSTUN_MAX_FLOWS(1,024), the handler returned without consuming the pending connection.With level-triggered epoll, the listening descriptor remained readable, potentially causing repeated network-worker wakeups without progress.
Root Cause
At maximum TCP flow capacity, the handler returned before accepting the pending connection. The listener therefore remained readable and could repeatedly trigger the worker.
Fix
accept4()before checking TCP flow capacity.Regression Test
Added
tests/nstun_tcp_capacity_test.cc, which:The test is integrated into the Makefile and supports PASS, FAIL, and SKIP outcomes. Exit code 77 indicates insufficient file-descriptor limits.
Verification
Original implementation:
Patched implementation:
Additional local validation:
--helpsmoke test passed.git diff --checkpassed.Run the focused regression test:
The complete privileged upstream integration suite and real guest-TUN integration tests were not executed.
Security and Availability Impact
Local testing demonstrated temporary excessive network-worker CPU consumption under TCP flow-saturation conditions.
The fix consumes and closes the excess connection, preventing it from continuously leaving the listener readable.
The observed condition recovered automatically in local testing. Remote exploitability, indefinite CPU exhaustion, and production-wide denial of service have not been established.
Files Changed
nstun/tcp.cc— Fix TCP accept/capacity-check ordering.tests/nstun_tcp_capacity_test.cc— Add regression coverage.Makefile— Integrate the regression test.