Skip to content

Fix bug with TCP bind w/ SO_REUSEADDR.#6238

Merged
copybara-service[bot] merged 1 commit intomasterfrom
test/cl381299527
Jul 1, 2021
Merged

Fix bug with TCP bind w/ SO_REUSEADDR.#6238
copybara-service[bot] merged 1 commit intomasterfrom
test/cl381299527

Conversation

@copybara-service
Copy link
Copy Markdown

Fix bug with TCP bind w/ SO_REUSEADDR.

In gVisor today its possible that when trying to bind a TCP socket
w/ SO_REUSEADDR specified and requesting the kernel pick a port by
setting port to zero can result in a previously bound port being
returned. This behaviour is incorrect as the user is clearly requesting
a free port. The behaviour is fine when the user explicity specifies
a port.

This change now checks if the user specified a port when making a port
reservation for a TCP port and only returns unbound ports even if
SO_REUSEADDR was specified.

Fixes #6209

@copybara-service copybara-service Bot added the exported Issue was exported automatically label Jun 24, 2021
@google-cla google-cla Bot added the cla: yes CLA has been signed label Jun 24, 2021
@copybara-service copybara-service Bot force-pushed the test/cl381299527 branch 2 times, most recently from 282b932 to 2477133 Compare July 1, 2021 21:09
In gVisor today its possible that when trying to bind a TCP socket
w/ SO_REUSEADDR specified and requesting the kernel pick a port by
setting port to zero can result in a previously bound port being
returned. This behaviour is incorrect as the user is clearly requesting
a free port. The behaviour is fine when the user explicity specifies
a port.

This change now checks if the user specified a port when making a port
reservation for a TCP port and only returns unbound ports even if
SO_REUSEADDR was specified.

Fixes #6209

PiperOrigin-RevId: 382607638
@copybara-service copybara-service Bot merged commit 570ca57 into master Jul 1, 2021
@copybara-service copybara-service Bot deleted the test/cl381299527 branch July 1, 2021 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes CLA has been signed exported Issue was exported automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SO_REUSEADDR causes system-allocated ports to overlap

1 participant