]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
tcp: fix access to sk->sk_state in tcp_poll()
authorDavide Caratti <dcaratti@redhat.com>
Wed, 26 Apr 2017 17:07:35 +0000 (19:07 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 1 May 2017 02:24:16 +0000 (22:24 -0400)
avoid direct access to sk->sk_state when tcp_poll() is called on a socket
using active TCP fastopen with deferred connect. Use local variable
'state', which stores the result of sk_state_load(), like it was done in
commit 00fd38d938db ("tcp: ensure proper barriers in lockless contexts").

Fixes: 19f6d3f3c842 ("net/tcp-fastopen: Add new API support")
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Acked-by: Wei Wang <weiwan@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp.c

index 059dad7deefe883bd3a26c93f27637dc22ccefda..1e4c76d2b8278ba71d6cc2cf7ebfe483e241f76e 100644 (file)
@@ -533,7 +533,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
 
                if (tp->urg_data & TCP_URG_VALID)
                        mask |= POLLPRI;
-       } else if (sk->sk_state == TCP_SYN_SENT && inet_sk(sk)->defer_connect) {
+       } else if (state == TCP_SYN_SENT && inet_sk(sk)->defer_connect) {
                /* Active TCP fastopen socket with defer_connect
                 * Return POLLOUT so application can call write()
                 * in order for kernel to generate SYN+data