diff options
author | Mithun Iyer <iyerm@google.com> | 2021-06-01 23:34:58 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-06-01 23:37:48 -0700 |
commit | 9357b4f7eb51b78311cb7d6478d5ac3bfcf79948 (patch) | |
tree | 0c8e40228dd220b58c240551e611979fdad00097 /pkg/usermem | |
parent | 12f4118437584c4a0e4738b9dde3e1885cef3de8 (diff) |
Ensure full shutdown of endpoint on notifyClose
Address a race with non-blocking connect and socket close, causing the
FIN (because of socket close) to not be sent out, even after completing
the handshake.
The race occurs with this sequence:
(1) endpoint Connect starts handshake, sending out SYN
(2) handshake complete() releases endpoint lock, waiting on sleeper.Fetch()
(3) endpoint Close acquires endpoint lock, does not enqueue FIN (as the
endpoint is not yet connected) and asserts notifyClose
(4) SYNACK from peer gets enqueued asserting newSegmentWaker
(5) handshake complete() re-aqcuires lock, first processes newSegmentWaker
event, transitions to ESTABLISHED and proceeds to protocolMainLoop()
(6) protocolMainLoop() exits while processing notifyClose
When the execution follows the above sequence, no FIN is sent to the peer.
This causes the listener side to have a half-open connection sitting in
the accept queue.
Fix this by ensuring that the protocolMainLoop() performs clean shutdown
when the endpoint state is still ESTABLISHED.
This would not be a bug, if during handshake complete(), sleeper.Fetch()
prioritized notificationWaker over newSegmentWaker. In that case, the
handshake would not have completed in (5) above.
Fixes #6067
PiperOrigin-RevId: 376994395
Diffstat (limited to 'pkg/usermem')
0 files changed, 0 insertions, 0 deletions