Skip to content

Commit 499350a

Browse files
tracywwnjdavem330
authored andcommitted
tcp: initialize rcv_mss to TCP_MIN_MSS instead of 0
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 <[email protected]> Signed-off-by: Wei Wang <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: Neal Cardwell <[email protected]> Signed-off-by: Yuchung Cheng <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 23416e2 commit 499350a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/ipv4/tcp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,6 +2320,10 @@ int tcp_disconnect(struct sock *sk, int flags)
23202320
tcp_set_ca_state(sk, TCP_CA_Open);
23212321
tcp_clear_retrans(tp);
23222322
inet_csk_delack_init(sk);
2323+
/* Initialize rcv_mss to TCP_MIN_MSS to avoid division by 0
2324+
* issue in __tcp_select_window()
2325+
*/
2326+
icsk->icsk_ack.rcv_mss = TCP_MIN_MSS;
23232327
tcp_init_send_head(sk);
23242328
memset(&tp->rx_opt, 0, sizeof(tp->rx_opt));
23252329
__sk_dst_reset(sk);

0 commit comments

Comments
 (0)