diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index c8cfe784c79a..47b147ca69d1 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3241,8 +3241,19 @@ restart: sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[bucket].chain) { struct inet_sock *inet = inet_sk(sk); + if (sk->sk_state == TCP_TIME_WAIT) { + /* + * Sockets that are in TIME_WAIT state are + * instances of lightweight inet_timewait_sock, + * we should simply skip them (or we'll try to + * access non-existing fields and crash). + */ + continue; + } + if (sysctl_ip_dynaddr && sk->sk_state == TCP_SYN_SENT) continue; + if (sock_flag(sk, SOCK_DEAD)) continue;