diff options
author | Eric Dumazet <edumazet@google.com> | 2017-03-03 17:08:21 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-03-22 07:43:33 -0400 |
commit | 07753bc6a2816c1c3b9f7bff133251f623c7bc91 (patch) | |
tree | 72b9554719075474e4a5b1c6ce96fd732a04217c /net | |
parent | 4547f03d1a624d7e92c65077b7cb5b2a33839cb3 (diff) |
tcp: fix various issues for sockets morphing to listen state
[ Upstream commit 02b2faaf0af1d85585f6d6980e286d53612acfc2 ]
Dmitry Vyukov reported a divide by 0 triggered by syzkaller, exploiting
tcp_disconnect() path that was never really considered and/or used
before syzkaller ;)
I was not able to reproduce the bug, but it seems issues here are the
three possible actions that assumed they would never trigger on a
listener.
1) tcp_write_timer_handler
2) tcp_delack_timer_handler
3) MTU reduction
Only IPv6 MTU reduction was properly testing TCP_CLOSE and TCP_LISTEN
states from tcp_v6_mtu_reduced()
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 7 | ||||
-rw-r--r-- | net/ipv4/tcp_timer.c | 6 |
2 files changed, 9 insertions, 4 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 2259114c7242..5bb809f12ba1 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -269,10 +269,13 @@ EXPORT_SYMBOL(tcp_v4_connect); | |||
269 | */ | 269 | */ |
270 | void tcp_v4_mtu_reduced(struct sock *sk) | 270 | void tcp_v4_mtu_reduced(struct sock *sk) |
271 | { | 271 | { |
272 | struct dst_entry *dst; | ||
273 | struct inet_sock *inet = inet_sk(sk); | 272 | struct inet_sock *inet = inet_sk(sk); |
274 | u32 mtu = tcp_sk(sk)->mtu_info; | 273 | struct dst_entry *dst; |
274 | u32 mtu; | ||
275 | 275 | ||
276 | if ((1 << sk->sk_state) & (TCPF_LISTEN | TCPF_CLOSE)) | ||
277 | return; | ||
278 | mtu = tcp_sk(sk)->mtu_info; | ||
276 | dst = inet_csk_update_pmtu(sk, mtu); | 279 | dst = inet_csk_update_pmtu(sk, mtu); |
277 | if (!dst) | 280 | if (!dst) |
278 | return; | 281 | return; |
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 3ea1cf804748..b1e65b3b4361 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c | |||
@@ -249,7 +249,8 @@ void tcp_delack_timer_handler(struct sock *sk) | |||
249 | 249 | ||
250 | sk_mem_reclaim_partial(sk); | 250 | sk_mem_reclaim_partial(sk); |
251 | 251 | ||
252 | if (sk->sk_state == TCP_CLOSE || !(icsk->icsk_ack.pending & ICSK_ACK_TIMER)) | 252 | if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) || |
253 | !(icsk->icsk_ack.pending & ICSK_ACK_TIMER)) | ||
253 | goto out; | 254 | goto out; |
254 | 255 | ||
255 | if (time_after(icsk->icsk_ack.timeout, jiffies)) { | 256 | if (time_after(icsk->icsk_ack.timeout, jiffies)) { |
@@ -552,7 +553,8 @@ void tcp_write_timer_handler(struct sock *sk) | |||
552 | struct inet_connection_sock *icsk = inet_csk(sk); | 553 | struct inet_connection_sock *icsk = inet_csk(sk); |
553 | int event; | 554 | int event; |
554 | 555 | ||
555 | if (sk->sk_state == TCP_CLOSE || !icsk->icsk_pending) | 556 | if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) || |
557 | !icsk->icsk_pending) | ||
556 | goto out; | 558 | goto out; |
557 | 559 | ||
558 | if (time_after(icsk->icsk_timeout, jiffies)) { | 560 | if (time_after(icsk->icsk_timeout, jiffies)) { |