• Eric Dumazet's avatar
    tcp: fix fastopen races vs lockless listener · 7656d842
    Eric Dumazet authored
    There are multiple races that need fixes :
    
    1) skb_get() + queue skb + kfree_skb() is racy
    
    An accept() can be done on another cpu, data consumed immediately.
    tcp_recvmsg() uses __kfree_skb() as it is assumed all skb found in
    socket receive queue are private.
    
    Then the kfree_skb() in tcp_rcv_state_process() uses an already freed skb
    
    2) tcp_reqsk_record_syn() needs to be done before tcp_try_fastopen()
    for the same reasons.
    
    3) We want to send the SYNACK before queueing child into accept queue,
    otherwise we might reintroduce the ooo issue fixed in
    commit 7c85af88 ("tcp: avoid reorders for TFO passive connections")
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    7656d842
tcp_input.c 178 KB