[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1c8f00de-552b-fff7-f8a8-cb98545ffafa@jp.fujitsu.com>
Date: Thu, 30 Mar 2017 12:48:34 +0900
From: Seiichi Ikarashi <s.ikarashi@...fujitsu.com>
To: Eric Dumazet <eric.dumazet@...il.com>
CC: <netdev@...r.kernel.org>
Subject: Re: [PATCH] tcp: possible race between tcp_done() and tcp_poll()
On 2017-03-30 12:18, Eric Dumazet wrote:
> 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
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.
>
> 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