[CVE-2017-14106,T/X/Z,SRU] tcp: initialize rcv_mss to TCP_MIN_MSS instead of 0

Message ID 20170911062338.9825-2-po-hsu.lin@canonical.com
State New
Headers show
Series
  • [CVE-2017-14106,T/X/Z,SRU] tcp: initialize rcv_mss to TCP_MIN_MSS instead of 0
Related show

Commit Message

Po-Hsu Lin Sept. 11, 2017, 6:23 a.m.
From: Wei Wang <weiwan@google.com>

CVE-2017-14106

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>
(cherry picked from commit 499350a5a6e7512d9ed369ed63a4244b6536f4f8)
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
 net/ipv4/tcp.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Stefan Bader Sept. 11, 2017, 11:46 a.m. | #1
On 11.09.2017 08:23, Po-Hsu Lin wrote:
> From: Wei Wang <weiwan@google.com>
> 
> CVE-2017-14106
> 
> 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>
> (cherry picked from commit 499350a5a6e7512d9ed369ed63a4244b6536f4f8)
> Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>

> ---
>  net/ipv4/tcp.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 16b5118..46c45a0 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -2202,6 +2202,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);
>
Colin King Sept. 11, 2017, 12:35 p.m. | #2
On 11/09/17 07:23, Po-Hsu Lin wrote:
> From: Wei Wang <weiwan@google.com>
> 
> CVE-2017-14106
> 
> 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>
> (cherry picked from commit 499350a5a6e7512d9ed369ed63a4244b6536f4f8)
> Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
> ---
>  net/ipv4/tcp.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 16b5118..46c45a0 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -2202,6 +2202,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);
> 
Clean cherry pick, looks OK.

Acked-by: Colin Ian King <colin.king@canonical.com>
Stefan Bader Sept. 15, 2017, 1:34 p.m. | #3
On 11.09.2017 08:23, Po-Hsu Lin wrote:
> From: Wei Wang <weiwan@google.com>
> 
> CVE-2017-14106
> 
> 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>
> (cherry picked from commit 499350a5a6e7512d9ed369ed63a4244b6536f4f8)
> Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
> ---
>  net/ipv4/tcp.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 16b5118..46c45a0 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -2202,6 +2202,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);
> 
Applied to Trusty, Xenial, and Zesty master-next

Patch

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 16b5118..46c45a0 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2202,6 +2202,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);