Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Apr 2020 22:01:33 +0000 (UTC)
From:      Richard Scheffenegger <rscheff@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r360479 - in head/sys/netinet: . tcp_stacks
Message-ID:  <202004292201.03TM1XgU031146@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rscheff
Date: Wed Apr 29 22:01:33 2020
New Revision: 360479
URL: https://svnweb.freebsd.org/changeset/base/360479

Log:
  Prevent premature shrinking of the scaled receive window
  which can cause a TCP client to use invalid or stale TCP sequence numbers for ACK packets.
  
  Packets with old sequence numbers are ignored and not used to update the send window size.
  This might cause the TCP session to hang indefinitely under some circumstances.
  
  Reported by:	Cui Cheng
  Reviewed by:	tuexen (mentor), rgrimes (mentor)
  Approved by:	tuexen (mentor), rgrimes (mentor)
  MFC after:	3 weeks
  Sponsored by:	NetApp, Inc.
  Differential Revision:	https://reviews.freebsd.org/D24515

Modified:
  head/sys/netinet/tcp_output.c
  head/sys/netinet/tcp_stacks/bbr.c
  head/sys/netinet/tcp_stacks/rack.c

Modified: head/sys/netinet/tcp_output.c
==============================================================================
--- head/sys/netinet/tcp_output.c	Wed Apr 29 21:54:09 2020	(r360478)
+++ head/sys/netinet/tcp_output.c	Wed Apr 29 22:01:33 2020	(r360479)
@@ -1238,8 +1238,11 @@ send:
 	if (flags & TH_SYN)
 		th->th_win = htons((u_short)
 				(min(sbspace(&so->so_rcv), TCP_MAXWIN)));
-	else
+	else {
+		/* Avoid shrinking window with window scaling. */
+		recwin = roundup2(recwin, 1 << tp->rcv_scale);
 		th->th_win = htons((u_short)(recwin >> tp->rcv_scale));
+	}
 
 	/*
 	 * Adjust the RXWIN0SENT flag - indicate that we have advertised

Modified: head/sys/netinet/tcp_stacks/bbr.c
==============================================================================
--- head/sys/netinet/tcp_stacks/bbr.c	Wed Apr 29 21:54:09 2020	(r360478)
+++ head/sys/netinet/tcp_stacks/bbr.c	Wed Apr 29 22:01:33 2020	(r360479)
@@ -13756,8 +13756,11 @@ send:
 	if (flags & TH_SYN)
 		th->th_win = htons((u_short)
 		    (min(sbspace(&so->so_rcv), TCP_MAXWIN)));
-	else
+	else {
+		/* Avoid shrinking window with window scaling. */
+		recwin = roundup2(recwin, 1 << tp->rcv_scale);
 		th->th_win = htons((u_short)(recwin >> tp->rcv_scale));
+	}
 	/*
 	 * Adjust the RXWIN0SENT flag - indicate that we have advertised a 0
 	 * window.  This may cause the remote transmitter to stall.  This

Modified: head/sys/netinet/tcp_stacks/rack.c
==============================================================================
--- head/sys/netinet/tcp_stacks/rack.c	Wed Apr 29 21:54:09 2020	(r360478)
+++ head/sys/netinet/tcp_stacks/rack.c	Wed Apr 29 22:01:33 2020	(r360479)
@@ -9572,8 +9572,11 @@ send:
 	if (flags & TH_SYN)
 		th->th_win = htons((u_short)
 		    (min(sbspace(&so->so_rcv), TCP_MAXWIN)));
-	else
+	else {
+		/* Avoid shrinking window with window scaling. */
+		recwin = roundup2(recwin, 1 << tp->rcv_scale);
 		th->th_win = htons((u_short)(recwin >> tp->rcv_scale));
+	}
 	/*
 	 * Adjust the RXWIN0SENT flag - indicate that we have advertised a 0
 	 * window.  This may cause the remote transmitter to stall.  This



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202004292201.03TM1XgU031146>