Skip to content

Commit 611a98c

Browse files
tracywwnjgregkh
authored andcommitted
tcp: initialize rcv_mss to TCP_MIN_MSS instead of 0
[ Upstream commit 499350a5a6e7512d9ed369ed63a4244b6536f4f8 ] When tcp_disconnect() is called, inet_csk_delack_init() sets icsk->icsk_ack.rcv_mss to 0. This could potentially cause tcp_recvmsg() => tcp_cleanup_rbuf() => __tcp_select_window() call path to have division by 0 issue. So this patch initializes rcv_mss to TCP_MIN_MSS instead of 0. Reported-by: Andrey Konovalov <andreyknvl@google.com> Signed-off-by: Wei Wang <weiwan@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: Yuchung Cheng <ycheng@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 081be8c commit 611a98c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

net/ipv4/tcp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,6 +2260,10 @@ int tcp_disconnect(struct sock *sk, int flags)
22602260
tcp_set_ca_state(sk, TCP_CA_Open);
22612261
tcp_clear_retrans(tp);
22622262
inet_csk_delack_init(sk);
2263+
/* Initialize rcv_mss to TCP_MIN_MSS to avoid division by 0
2264+
* issue in __tcp_select_window()
2265+
*/
2266+
icsk->icsk_ack.rcv_mss = TCP_MIN_MSS;
22632267
tcp_init_send_head(sk);
22642268
memset(&tp->rx_opt, 0, sizeof(tp->rx_opt));
22652269
__sk_dst_reset(sk);

0 commit comments

Comments
 (0)