From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay.kraftway.ru (relay.kraftway.ru [91.198.14.19]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 936F120D2C3BA for ; Tue, 28 Mar 2017 00:20:28 -0700 (PDT) Received: from M-MAIL1.kraftway.lan ([169.254.1.160]) by M-MAILGATE2.kraftway.lan ([10.0.1.204]) with mapi id 14.03.0319.002; Tue, 28 Mar 2017 10:20:26 +0300 From: "atepin@kraftway.ru" To: "edk2-devel@lists.01.org" Thread-Topic: [PATCH 2/2] NetworkPkg/TcpDxe: Fix unconditional window shrinking Thread-Index: AQHSp5PF4qoi6c2GBUS6rl+rAOsGnQ== Date: Tue, 28 Mar 2017 07:20:26 +0000 Message-ID: References: In-Reply-To: Accept-Language: ru-RU, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.0.1.146] MIME-Version: 1.0 Subject: [PATCH 2/2] NetworkPkg/TcpDxe: Fix unconditional window shrinking X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Mar 2017 07:20:29 -0000 Content-Language: en-US Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: quoted-printable Moving Right window edge to the left on sender side without additional checks leads to the situation when sender assumes the receiver shrunk its rcv buffer, when, in fact, it only reduced window size. This is a TCP deadlock situation. Receiver ACKs proper segment, while sender discards it for future ACK. Add check for negative usable window to prevent erroneous window shrinking. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Andrey Tepin --- NetworkPkg/TcpDxe/TcpInput.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/NetworkPkg/TcpDxe/TcpInput.c b/NetworkPkg/TcpDxe/TcpInput.c index 04c8a82..11b3eb8 100644 --- a/NetworkPkg/TcpDxe/TcpInput.c +++ b/NetworkPkg/TcpDxe/TcpInput.c @@ -738,6 +738,7 @@ TcpInput ( TCP_SEQNO Right; TCP_SEQNO Urg; UINT16 Checksum; + INT32 UsableWnd; =20 ASSERT ((Version =3D=3D IP_VERSION_4) || (Version =3D=3D IP_VERSION_6)); =20 @@ -1307,7 +1308,10 @@ TcpInput ( =20 if (TCP_SEQ_LT (Right, Tcb->SndNxt)) { =20 - Tcb->SndNxt =3D Right; + UsableWnd =3D Tcb->SndUna + Tcb->SndWnd - Tcb->SndNxt; + if (UsableWnd < 0) { + Tcb->SndNxt =3D Right; + } =20 if (Right =3D=3D Tcb->SndUna) { =20 --=20 1.9.1