tcp: tcp_data_ready() must look at SOCK_DONE
Subsystems (3)
PATCH 1/1 tcp: tcp_data_ready() must look at SOCK_DONE
From: Eric Dumazet <[email protected]>
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
--- net/ipv4/tcp_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_input.c +1 -1
@@ -4924,7 +4924,7 @@ int tcp_send_rcvq(struct sock *sk, struct msghdr *msg, size_t size)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); }
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
Quoted 11 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
My prior cleanup missed that
tcp_data_ready()has to look atSOCK_DONE. Otherwise, an application usingSO_RCVLOWATwill not get EPOLLIN event if a FIN is received in the middle of expected payload.The reason
SOCK_DONEis not examined intcp_epollin_ready()is thattcp_poll()catches the FIN becausetcp_fin()is also settingRCV_SHUTDOWNintosk->sk_shutdown
Quoted 5 lines
Fixes 05dc72aba364 ("tcp: factorize logic into tcp_epollin_ready()")Signed-off-by Eric Dumazet <[email protected]>Reported-by Wei Wang <[email protected]>Cc Arjun Roy <[email protected]>---
Thanks Eric for the fix!
Quoted 19 lines
net/ipv4/tcp_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/ipv4/tcp_input.c +1
-2@@ -4924,7 +4924,7 @@ int tcp_send_rcvq(struct sock *sk, struct msghdr *msg, size_t size)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); } --2.30.0.478.g8a0d178c01-goog
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 11 lines · On Sat, 13 Feb 2021 06:26:34 -0800 you wrote:
From: Eric Dumazet <[email protected]>
My prior cleanup missed that
tcp_data_ready()has to look atSOCK_DONE. Otherwise, an application usingSO_RCVLOWATwill not get EPOLLIN event if a FIN is received in the middle of expected payload.The reason
SOCK_DONEis not examined intcp_epollin_ready()is thattcp_poll()catches the FIN becausetcp_fin()is also settingRCV_SHUTDOWNintosk->sk_shutdown[...]
Here is the summary with links:
- [net-next] tcp: tcp_data_ready() must look at SOCK_DONE
https://git.kernel.org/netdev/net-next/c/39354eb29f59
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html