tcp: tcp_data_ready() must look at SOCK_DONE
authorEric Dumazet <edumazet@google.com>
Sat, 13 Feb 2021 14:26:34 +0000 (06:26 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 15 Feb 2021 21:20:36 +0000 (13:20 -0800)
My prior cleanup missed that tcp_data_ready() has to look at SOCK_DONE.
Otherwise, an application using SO_RCVLOWAT will not get EPOLLIN event
if a FIN is received in the middle of expected payload.

The reason SOCK_DONE is not examined in tcp_epollin_ready()
is that tcp_poll() catches the FIN because tcp_fin()
is also setting RCV_SHUTDOWN into sk->sk_shutdown

Fixes: 05dc72aba364 ("tcp: factorize logic into tcp_epollin_ready()")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Wei Wang <weiwan@google.com>
Cc: Arjun Roy <arjunroy@google.com>
Reviewed-by: Wei Wang <weiwan@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp_input.c

index e32a7056cb7640c67ef2d6a4d9484684d2602fcd..69a545db80d2ead47ffcf2f3819a6d066e95f35d 100644 (file)
@@ -4924,7 +4924,7 @@ err:
 
 void tcp_data_ready(struct sock *sk)
 {
-       if (tcp_epollin_ready(sk, sk->sk_rcvlowat))
+       if (tcp_epollin_ready(sk, sk->sk_rcvlowat) || sock_flag(sk, SOCK_DONE))
                sk->sk_data_ready(sk);
 }