From nobody Mon Feb 9 08:30:21 2026 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 599FA331A55 for ; Thu, 23 Oct 2025 14:48:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761230919; cv=none; b=NCylpQdjDG8S1bLQb6iKYY/bb8yR9yIsyWK27x2sMcsDfC1IB13LCWfTWog00WGHxmmAhl7jcW5MF5j06XYSs2C/2T+nYEx0eScAA01PdrB810zPUneE7I370+b3cTDm5jIP02B0dZMQp28LsJbAHhNtvOtfIpyT7halzNDV0jE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761230919; c=relaxed/simple; bh=JZj9auJ7JYGycI9LrR62D2gYRthD2d4QaIrDPfu4Mqw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=owcXPDzPUhu5PDubJcLd+VNIoDD3wMs4vjsYkF6bcPAkwzrtFfJzop2cX3izADw9fFR0bTdGve5KMlrs3OYmS9iC17Sf2iQ9ZoZNO7E6mTZIsnrX1XdYcXOEhQCNGMm67CFc1ek3Qza086DhEbaKV8Sa8ZfLRYYlwLS3OyDN/gw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dO93ORRL; arc=none smtp.client-ip=209.85.216.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dO93ORRL" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-33db8fde85cso1046571a91.0 for ; Thu, 23 Oct 2025 07:48:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761230918; x=1761835718; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=szAE+bPsPINah1q0UtkV9PIi4Hs5RhSjEz/DHr/a1dA=; b=dO93ORRL7KkyXq0+NXln1mFyTwiweCqMNAFLLXmbyk045Sg0mJKbPLaejnBI/YlkH/ 2hHayxoU6KHPv8jj1srDaNrJUN2Xf1A1VRNjZ5Bry73Syj7emY1pPKXlIhivM0Nv6cyU Xdg8BTP/apvzx6lMdh8ucMah7YvnKRd2cdsA4Y2BVRLoO6ciXfdg2zQ6PL/jAsh5ehxt RiZnNCLbV14mDFwXxIN01cA52HT5z4saAw3Nqn2wq/laCQs6jnX3DFHy2ylbhbzuyrPX fW6H7svavJHJNroVxXs7Es7ricFfSYOshVbIeZSE/gELMIga1xriyfuXoqD+G2KYHrpj ugNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761230918; x=1761835718; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=szAE+bPsPINah1q0UtkV9PIi4Hs5RhSjEz/DHr/a1dA=; b=EB4NnqRqC7gy211NFT1X7UuAPU+46YHIc0XjzTRQq25dF6UjHWwc73RSzEYt4V5+J7 iNxyHtH3ZXa/3uiVa/Ub0Y394z8W7990QC7zEQPgEQkZSRVk6eGOm7uVZzRQUnqjlUvy f1zoTzBKQwDaAQcjDcbKNcK3up7U2izafhGNKtr8S2Iu9cpinZLlkb98oWHQRjEVLMJb TrrDEOUrN8kscurtPeusJ5t26acwieEKZmnnMiMJh+cIJxJrDVG/OJbHMOhklJcjQeE4 5SVs7QdkgfPhvRy4U2Q8XZzJqa0IDPg4yLRMCXVLhOj5psmQKN+JFd8kE1n0cVA12iF0 +rew== X-Forwarded-Encrypted: i=1; AJvYcCVTvCd/QKdoJngzwGRNLpFEyKLcFmUcA3doO52zFpZQcgb2bFdnh7H2Me5S8aQkS5zeRyzia/C/rihUFAg=@vger.kernel.org X-Gm-Message-State: AOJu0YxOCvRnTFZTK5QPrYJCDLNrBIY1xEifWs6pz+awylT1icPnvyjo vw52H4OqI/iY5ni++M1xz9oaEfMX37pdvNhiHkoaDNCgVYZ/aTpE93Ny X-Gm-Gg: ASbGncvV7wTAH5AYHQNaY8LsaixCpNMarSHCDVjVThiYtlkFE8xd1JeYFqllN4RF13x MeyDl9268V4sW0VwQ9abqoqc04VcXlXcorU9VtKR06n+ezyxm/HyLpp7/1rpYlndz2MEm6A+Bli WPq1kJRnuP3tKPsSCgw6CuCsD4dtVc3JssYhPdzNdud4QSc1SFwtUdg0bhTbptJjtTNTpwzjvVv JaI0JaKuWn3HaC078aVe83vDF97k0ANhJRIfmbBV4qGQo90ALwESJnzL8P/HSOu9/IHPGK2jqnl GP+VE+L3zUKVk6lo9r1F5emumuxtRqjaUi32BLohBdGbSWp6WRm75Nt7xir5Yv9gQMK6fa2Ltw1 NhdcxIQItSy7N36IMw2b/vcmCgh1rjtI2mHwQHRhKsMnVdvrgqS3EvybdtivWBdQKK968E6kdZL OmPGu2+VxDCJWTFeVdwlL5Tq4= X-Google-Smtp-Source: AGHT+IHFnP+dNzR2Yod0rw+D0nRCh4IMvaIH69R6QfSNYJtyQuMQ9Y/Stv1TY6C8rzjwn4OZCUgTnw== X-Received: by 2002:a17:90b:28c4:b0:330:852e:2bcc with SMTP id 98e67ed59e1d1-33bcf8e6348mr32236334a91.21.1761230917698; Thu, 23 Oct 2025 07:48:37 -0700 (PDT) Received: from localhost.localdomain ([150.109.25.78]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-33e2247a7f1sm6045716a91.14.2025.10.23.07.48.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Oct 2025 07:48:37 -0700 (PDT) From: HaiYang Zhong X-Google-Original-From: HaiYang Zhong To: edumazet@google.com Cc: ncardwell@google.com, kuniyu@google.com, davem@davemloft.net, dsahern@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, wokezhong@tencent.com Subject: [PATCH v2 1/2] net/tcp: fix permanent FIN-WAIT-1 state with continuous zero window packets Date: Thu, 23 Oct 2025 22:48:04 +0800 Message-ID: <20251023144805.1979484-2-wokezhong@tencent.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: <20251023144805.1979484-1-wokezhong@tencent.com> References: <20251023144805.1979484-1-wokezhong@tencent.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a TCP connection is in FIN-WAIT-1 state with the FIN packet blocked in the send buffer, and the peer continuously sends zero-window advertisements, the current implementation reset the zero-window probe timer while maintain= ing the current `icsk->icsk_backoff`, causing the connection to remain permanen= tly in FIN-WAIT-1 state. Reproduce conditions: 1. Peer's receive window is full and actively sending continuous zero window advertisements. 2. Local FIN packet is blocked in send buffer due to peer's zero-window. 3. Local socket has been closed (entered orphan state). The root cause lies in the tcp_ack_probe() function: when receiving a zero-= window ACK, - It reset the probe timer while keeping the current `icsk->icsk_backoff`. - This would result in the condition `icsk->icsk_backoff >=3D max_probes` f= alse. - Orphaned socket cannot be set to close. This patch modifies the tcp_ack_probe() logic: when the socket is dead, upon receiving a zero-window packet, instead of resetting the probe timer, we maintain the current timer, ensuring the probe interval grows according to 'icsk->icsk_backoff', thus causing the zero-window probe timer to eventu= ally timeout and close the socket. Signed-off-by: HaiYang Zhong --- net/ipv4/tcp_input.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 71b76e98371a..22fc82cb6b73 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -3440,6 +3440,8 @@ static void tcp_ack_probe(struct sock *sk) } else { unsigned long when =3D tcp_probe0_when(sk, tcp_rto_max(sk)); =20 + if (sock_flag(sk, SOCK_DEAD) && icsk->icsk_backoff !=3D 0) + return; when =3D tcp_clamp_probe0_to_user_timeout(sk, when); tcp_reset_xmit_timer(sk, ICSK_TIME_PROBE0, when, true); } --=20 2.43.7 From nobody Mon Feb 9 08:30:21 2026 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7376A33291E for ; Thu, 23 Oct 2025 14:48:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761230923; cv=none; b=sdkZ5nqvqUGnpRiE6sr5Nxeq2y0+KJXTxb8uvV81MBmoOymbIlMRScZ8klLfQlqrdUknCEWn/OzzqLCFmsyQmXch3GGK+AR9r6+8WBYj5WsEx4erz+BXkLq6bJ4oSKxLeJqDBttNwFFPV9t21af/6H4SiSkqHgo+q/HOZuOycrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761230923; c=relaxed/simple; bh=dkFalx35Mf7Ek+Fkx2R9b5eye892DdLAQIXR7osART4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zc0noZR/8QBWHtOQIWshaPLl4WW85EMSnZCQE/X9S8szdzTGV8CdGaRqrRIQI2G8cZ5MFac/xCrvCyhIusOxb/kTUx8+ZkIs0NxegGYVgXBFFIOf8C2Y9YQ3VLZrnKkMGfwyGTW2+zu6g1aYLrdIDwaPJ4ZG2pLciUzmDkMy8nk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AahZCQgi; arc=none smtp.client-ip=209.85.216.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AahZCQgi" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-33d896debe5so1160157a91.0 for ; Thu, 23 Oct 2025 07:48:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761230922; x=1761835722; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nIyY0jwm6XINDoeFBx1e+QKbqj3iHSEYcQQKVDLzBek=; b=AahZCQgigInt18CzimkQzS7fm1Jsg7vvjabfSvE+CtBKINbREkkUtT/drKmlvuHJeu xss1X+cqxIib5+ki4zGVvBjRQxhLOQjnUbkXksj4d0ewo3jTfYgo0IbTFrb1qDor6E2d 0P/On70TnntK6c1Zx6WhvNKUskjKYqRSKDiBsR1pWK9r5cmCsD/dOvgaUSuINGxAo6S1 tkmcl+yv5/289leB6N+gQhIm90J1z871YfSLHBRsdg/f+oAN+WcOXut8figzin2nPIor dwSTbTDQk2VLoWwtVXKWSqFFKgmKojHuHygIwhKVvVg7MGnQIX6Kg2q7l/7kq2HGsniZ Uj8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761230922; x=1761835722; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nIyY0jwm6XINDoeFBx1e+QKbqj3iHSEYcQQKVDLzBek=; b=Z/6xgHGpziTd44ps954T5IMdTunzBZwYIXX7zZdJmlEEsfQoB8U276XoGKiEw4HqH/ LhRYU1jAXMEiZJCmeBjlqM36c5VXV/7M8uwNvMH457sjS/e6kkg9r3tLjkKvY3YJky9D 2QAWSiYd7b74I/ge3RdZHU9RO661wp/i16gMDkGzs84cgOq6irTOeIuwp6l9ysxV2XBT a1CjXra2vV4UoP5tuwq+kKHqhBFaK4YMhf8zx1QsL+mD2IFzQudybGW/T4owNxnJU3Tj wSMwEyB0UIBs+y85tZ+udatpxx/lnLKXCkxmgle6iZdaqFpdYr4e0UHPEqaZTLK03xLK PwWw== X-Forwarded-Encrypted: i=1; AJvYcCXbE2xyjZ3Uv7xGzhEnHFuT1gR4cCY+U6KVXbuOVoLVhVesBsHgfUXJpjNhNQuXThx+F4qUjU1D+wDe4DM=@vger.kernel.org X-Gm-Message-State: AOJu0YzwScyFQ+KpWDRKLH4sV879WVtt9aGiFG8BfHGkZqGZ8XT212rG ExDhbym9heZ4g5e4W9EZ9eeMJEOUIWpEqS4Btb4PP0Ge40jldzmNHgc5 X-Gm-Gg: ASbGncsG+NcnqmsFgiLD8PhMgjqj3OzdXczPxoEdeTF5I/X1apNsDTzQ6igJ+mPZ/eh cg5q9QBv8bMpCg9o40fNvhRDjoTuxOC1DhUMP1jwElJ52uPadnOJlJ6MhhFBcHkbby4VvdIk893 JNBgyydi1upvN3Qwovodbr/2B5H2DQ7oaCKg01zxr/b9JWSPFDYpmXDNeG/I4FyB3A1VEr70hjl 3GQdxiwreNQJ5NSkdtUB5gIa1GpWiCNpbupDC1KY8NcMf0lm3x6Rw4066pzEheLKw2iNCf0iGDN Da+/Ql/emXpEGPBK2xsdtAV7nNwuS+uusa7E2DDOixSa59YgDAWMuMUaHpXA0Bmyt001/15xzvd hVGQLYSbZ6SkboeXtEa/j0DiaZGwUoR2BmafZX5I+P5H2FCcC8EptY3HwiSzStGsfwFQDOVKU3Q C6Iq4YBmBzZmOzqQkXuARvtB8= X-Google-Smtp-Source: AGHT+IEXALud1vKs7yhSWKIJW7KB5/rjyWchLWdA7m4PkitrT3UlKVgb0yRvPH+Kg5clS7uGqXVOgA== X-Received: by 2002:a17:90b:35cf:b0:330:793a:4240 with SMTP id 98e67ed59e1d1-33bcf918506mr28258906a91.31.1761230921710; Thu, 23 Oct 2025 07:48:41 -0700 (PDT) Received: from localhost.localdomain ([150.109.25.78]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-33e2247a7f1sm6045716a91.14.2025.10.23.07.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Oct 2025 07:48:41 -0700 (PDT) From: HaiYang Zhong X-Google-Original-From: HaiYang Zhong To: edumazet@google.com Cc: ncardwell@google.com, kuniyu@google.com, davem@davemloft.net, dsahern@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, wokezhong@tencent.com Subject: [PATCH v2 2/2] net/tcp: add packetdrill test for FIN-WAIT-1 zero-window fix Date: Thu, 23 Oct 2025 22:48:05 +0800 Message-ID: <20251023144805.1979484-3-wokezhong@tencent.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: <20251023144805.1979484-1-wokezhong@tencent.com> References: <20251023144805.1979484-1-wokezhong@tencent.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add packetdrill test to reproduce and verify the permanent FIN-WAIT-1 state issue when continuous zero window packets are received. The test simulates: - TCP connection establishment - Peer advertising zero window - Local FIN blocked in send buffer due to zero window - Continuous zero window ACKs from peer - Verification of connection timeout (after fix) Signed-off-by: HaiYang Zhong --- .../net/tcp_fin_wait1_zero_window.pkt | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tools/testing/selftests/net/tcp_fin_wait1_zero_window.p= kt diff --git a/tools/testing/selftests/net/tcp_fin_wait1_zero_window.pkt b/to= ols/testing/selftests/net/tcp_fin_wait1_zero_window.pkt new file mode 100644 index 000000000000..86ceb95de744 --- /dev/null +++ b/tools/testing/selftests/net/tcp_fin_wait1_zero_window.pkt @@ -0,0 +1,58 @@ +// Test for permanent FIN-WAIT-1 state with continuous zero-window adverti= sements +// Author: HaiYang Zhong + + +0.000 socket(..., SOCK_STREAM, IPPROTO_TCP) =3D 3 +0.000 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) =3D 0 +0.000 bind(3, ..., ...) =3D 0 +0.000 listen(3, 1) =3D 0 + +0.100 < S 0:0(0) win 65535 +0.100 > S. 0:0(0) ack 1 +0.100 < . 1:1(0) ack 1 win 65535 +0.100 accept(3, ..., ...) =3D 4 + +// Send data to fill receive window +0.200 write(4, ..., 5) =3D 5 +0.200 > P. 1:6(5) ack 1 + +// Advertise zero-window +0.200 < . 1:1(0) ack 6 win 0 + +// Application closes connection, sends FIN (but blocked by zero window) +0.200 close(4) =3D 0 + +//Send zero-window probe packet ++0.200 > . 5:5(0) ack 1 ++0.400 > . 5:5(0) ack 1 ++0.800 > . 5:5(0) ack 1 ++1.600 > . 5:5(0) ack 1 ++3.200 > . 5:5(0) ack 1 ++6.400 > . 5:5(0) ack 1 ++12.800 > . 5:5(0) ack 1 + +// Continuously sending zero-window ACKs +30.000 < . 1:1(0) ack 6 win 0 + +// Key verification points +// Without fix: waiting for packet timeout due to timer reset +// With fix: this probe is sent as scheduled ++22.000~+23.000 > . 5:5(0) ack 1 + +// More zero-window ACKs from peer +60.000 < . 1:1(0) ack 6 win 0 +90.000 < . 1:1(0) ack 6 win 0 ++16.000~+19.000 > . 5:5(0) ack 1 +120.000 < . 1:1(0) ack 6 win 0 +150.000 < . 1:1(0) ack 6 win 0 +180.000 < . 1:1(0) ack 6 win 0 +210.000 < . 1:1(0) ack 6 win 0 ++0.000~+5.000 > . 5:5(0) ack 1 +240.000 < . 1:1(0) ack 6 win 0 +270.000 < . 1:1(0) ack 6 win 0 +300.000 < . 1:1(0) ack 6 win 0 +330.000 < . 1:1(0) ack 6 win 0 +360.000 < . 1:1(0) ack 6 win 0 + +// Connection reset after zero-window probe timeout ++0.000 > R 6:6(0) --=20 2.43.7