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 6E6E521954084 for ; Thu, 20 Apr 2017 02:30:43 -0700 (PDT) Received: from M-MAIL1.kraftway.lan ([169.254.1.160]) by m-mailgate1.kraftway.lan ([10.0.1.203]) with mapi id 14.03.0319.002; Thu, 20 Apr 2017 12:30:38 +0300 From: "atepin@kraftway.ru" To: "edk2-devel@lists.01.org" Thread-Topic: [PATCH v2 2/2] MdeModulePkg/Tcp4Dxe: Add wnd scale check before shrinking window Thread-Index: AQHSubjEzAMJ7hNqckmMvN6raxiBGg== Date: Thu, 20 Apr 2017 09:30:37 +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 v2 2/2] MdeModulePkg/Tcp4Dxe: Add wnd scale check before shrinking window 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: Thu, 20 Apr 2017 09:30:44 -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 check can lead to the TCP deadlock, when receiver ACKs proper segment, while sender discards it for future ACK. To prevent this add check if usable window (or shrink amount in this case) is bigger then receiver's window scale factor. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Andrey Tepin --- MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c b/MdeModule= Pkg/Universal/Network/Tcp4Dxe/Tcp4Input.c index 1000538..77110d8 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c @@ -1187,8 +1187,21 @@ TcpInput ( } =20 if (TCP_SEQ_LT (Right, Tcb->SndNxt)) { + DEBUG ( + (EFI_D_WARN, + "TcpInput: peer advise negative useable window for connected TCB= %p\n", + Tcb) + ); =20 - Tcb->SndNxt =3D Right; + INT32 Usable =3D Tcb->SndNxt - Right; + if ((Usable >> Tcb->SndWndScale) > 0) { + DEBUG ( + (EFI_D_WARN, + "TcpInput: SndNxt is out of window by more than window scale f= or TCB %p\n", + Tcb) + ); + Tcb->SndNxt =3D Right; + } =20 if (Right =3D=3D Tcb->SndUna) { =20 --=20 2.7.4