Skip to contentSkip to conversation

tcp: initialize rcv_mss to TCP_MIN_MSS instead of 0

PATCH Applied Wei Wang 2 participants 2 messages May 18, 2017 – May 21, 2017

Subsystems (3)
lore
Share & tools
lore

Wei Wang

author
#0 lore raw

PATCH 1/1 tcp: initialize rcv_mss to TCP_MIN_MSS instead of 0

From: Wei Wang <[email protected]>

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.

---
 net/ipv4/tcp.c | 4 ++++
 1 file changed, 4 insertions(+)
net/ipv4/tcp.c +4 -0
index 1e4c76d2b827..842b575f8fdd 100644
@@ -2320,6 +2320,10 @@ int tcp_disconnect(struct sock *sk, int flags)
 	tcp_set_ca_state(sk, TCP_CA_Open);
 	tcp_clear_retrans(tp);
 	inet_csk_delack_init(sk);
+	/* Initialize rcv_mss to TCP_MIN_MSS to avoid division by 0
+	 * issue in __tcp_select_window()
+	 */
+	icsk->icsk_ack.rcv_mss = TCP_MIN_MSS;
 	tcp_init_send_head(sk);
 	memset(&tp->rx_opt, 0, sizeof(tp->rx_opt));
 	__sk_dst_reset(sk);
Signature · 1 line
2.13.0.303.g4ebf302169-goog
maintainer Applied
#1 lore raw

From: Wei Wang <[email protected]>
Date: Thu, 18 May 2017 11:22:33 -0700

Quoted 8 lines

From: Wei Wang <[email protected]>

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.

Quoted 5 lines

Applied, thanks.