Skip to content
  • Michael Tuexen's avatar
    Fix race when accepting TCP connections. · fe1274ee
    Michael Tuexen authored
    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
    fe1274ee