lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 29 Mar 2017 20:18:03 -0700
From:   Eric Dumazet <eric.dumazet@...il.com>
To:     Seiichi Ikarashi <s.ikarashi@...fujitsu.com>
Cc:     netdev@...r.kernel.org
Subject: Re: [PATCH] tcp: possible race between tcp_done() and tcp_poll()

On Thu, 2017-03-30 at 11:55 +0900, Seiichi Ikarashi wrote:

> 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

Untested patch :

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);


Powered by blists - more mailing lists