HomeFreeBSD

Fix race when accepting TCP connections.

Description

Fix race when accepting TCP connections.

When expanding a SYN-cache entry to a socket/inp a two step approach was
taken:

  1. The local address was filled in, then the inp was added to the hash table.
  2. The remote address was filled in and the inp was relocated in the hash table.

Before the epoch changes, a write lock was held when this happens and
the code looking up entries was holding a corresponding read lock.
Since the read lock is gone away after the introduction of the
epochs, the half populated inp was found during lookup.
This resulted in processing TCP segments in the context of the wrong
TCP connection.
This patch changes the above procedure in a way that the inp is fully
populated before inserted into the hash table.

Thanks to Paul <devgs@ukr.net> for reporting the issue on the net@
mailing list and for testing the patch!

Reviewed by: rrs@
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D22971

Details

Provenance
tuexenAuthored on
Differential Revision
D22971: Fix race when accepting TCP connections
Parents
rS356662: nd6_rtr: constantly use __func__ for nd6log()
Branches
Unknown
Tags
Unknown