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 C39DE21954084 for ; Thu, 20 Apr 2017 02:30:42 -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; Thu, 20 Apr 2017 12:30:37 +0300 From: "atepin@kraftway.ru" To: "edk2-devel@lists.01.org" Thread-Topic: [PATCH v2 1/2] NetworkPkg/TcpDxe: Add wnd scale check before shrinking window Thread-Index: AQHSubjEuLbyQ48CkUmcRcigeg/piA== Date: Thu, 20 Apr 2017 09:30:37 +0000 Message-ID: <5efa583cfa4ddaecd9b1dcf8ac6999b4368e12e8.1492679770.git.atepin@kraftway.ru> 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 1/2] NetworkPkg/TcpDxe: 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:43 -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 --- NetworkPkg/TcpDxe/TcpInput.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/NetworkPkg/TcpDxe/TcpInput.c b/NetworkPkg/TcpDxe/TcpInput.c index 04c8a82..74ea02b 100644 --- a/NetworkPkg/TcpDxe/TcpInput.c +++ b/NetworkPkg/TcpDxe/TcpInput.c @@ -1306,8 +1306,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