From nobody Sun May 5 17:18:55 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1492680647096727.8459117327934; Thu, 20 Apr 2017 02:30:47 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C5FBB21954088; Thu, 20 Apr 2017 02:30:44 -0700 (PDT) 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 X-Original-To: edk2-devel@lists.01.org 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 Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.0.1.146] MIME-Version: 1.0 Subject: [edk2] [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: , Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Fu Siyuan --- 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 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun May 5 17:18:55 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1492680651759229.78210405889183; Thu, 20 Apr 2017 02:30:51 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2EBEB20082F02; Thu, 20 Apr 2017 02:30:45 -0700 (PDT) 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 X-Original-To: edk2-devel@lists.01.org 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 Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.0.1.146] MIME-Version: 1.0 Subject: [edk2] [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: , Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Fu Siyuan --- 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 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel