Thread (8 messages) 8 messages, 3 authors, 2017-03-30

Re: [PATCH] tcp: possible race between tcp_done() and tcp_poll()

From: Seiichi Ikarashi <hidden>
Date: 2017-03-30 03:49:48

On 2017-03-30 12:18, Eric Dumazet wrote:
On Thu, 2017-03-30 at 11:55 +0900, Seiichi Ikarashi wrote:
quoted
I got a report that receiving a RST packet but poll() got only POLLERR, no POLLIN|POLLRDHUP .
It was an old x86_64 kernel which does not include sk_state_{load,store} functions.
I suspected some race might have occur above.
It looks that a one-liner patch would be enough in tcp_done()

No need adding extra barriers
I agree.
sk->sk_shutdown seems not affect the behavior of both tcp_clear_xmit_timers()
and reqsk_fastopen_remove().
Untested patch :
Sorry, I cannot test it because I do not have a replication environment.
quoted hunk ↗ jump to hunk
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 1e319a525d51b0b603a5ccc5143381c752b9f2c7..4107d3fc00a53f768cdb885971a1067c810f5c9f 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3285,12 +3285,12 @@ void tcp_done(struct sock *sk)
 	if (sk->sk_state == TCP_SYN_SENT || sk->sk_state == TCP_SYN_RECV)
 		TCP_INC_STATS(sock_net(sk), TCP_MIB_ATTEMPTFAILS);
 
+	sk->sk_shutdown = SHUTDOWN_MASK;
 	tcp_set_state(sk, TCP_CLOSE);
 	tcp_clear_xmit_timers(sk);
 	if (req)
 		reqsk_fastopen_remove(sk, req, false);
 
-	sk->sk_shutdown = SHUTDOWN_MASK;
 
 	if (!sock_flag(sk, SOCK_DEAD))
 		sk->sk_state_change(sk);


Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help