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 <ate...@kraftway.ru>
---
 MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c 
b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c
index 1000538..ea0766a 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c
@@ -703,6 +703,7 @@ TcpInput (
   TCP_SEG     *Seg;
   TCP_SEQNO   Right;
   TCP_SEQNO   Urg;
+  INT32       UsableWnd;
 
   NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);
 
@@ -1188,7 +1189,10 @@ TcpInput (
 
       if (TCP_SEQ_LT (Right, Tcb->SndNxt)) {
 
-        Tcb->SndNxt = Right;
+        UsableWnd = Tcb->SndUna + Tcb->SndWnd - Tcb->SndNxt;
+        if (UsableWnd < 0) {
+          Tcb->SndNxt = Right;
+        }
 
         if (Right == Tcb->SndUna) {
 
-- 
1.9.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to