Article View: linux.kernel.netdev
Article #18655[PATCH net-next 1/2] tcp: do not accept ACK of our ISS on active opens
From: Eric Dumazet
Date: Wed, 18 Nov 2026 17:26
Date: Wed, 18 Nov 2026 17:26
121 lines
13348 bytes
13348 bytes
Michael Tuexen asked on the tcpm list [1] whether, after a completed
handshake, a segment with SEG.ACK == ISS is a duplicate ACK or a ghost
ACK. Flavius-Romeo Mazilu answered that Linux behaves differently
depending on which side opened the connection:
- passive opens drop it and send a challenge ACK,
- active opens accept it as an old duplicate ACK.
This comes from commit 3d501dd326fb ("tcp: do not accept ACK of bytes
we never sent"), which bounds the range of acceptable old ACKs
by tp->bytes_acked.
On active opens (including Fast Open and simultaneous opens),
tp->snd_una starts at ISS and the ACK of our SYN goes through
tcp_snd_una_update(), so tp->bytes_acked counts the SYN.
On passive opens, tp->snd_una starts at ISS + 1 and the SYN-ACK
is not counted.
The SYN is not a payload byte, and no valid ACK ever carried ISS:
the lowest ACK a peer can send on a synchronized connection is ISS + 1.
Counting the SYN widens the acceptable range by one sequence number.
tp->bytes_acked is exported to user space (tcpi_bytes_acked,
bpf_tcp_sock, bpf_sock_ops) and tools/testing/selftests/bpf expects
the SYN to be counted, so leave it unchanged.
Instead, remember in a new bit that our SYN was counted,
and subtract it in the tcp_ack() check.
Mazilu's observation was confirmed by code inspection and with
packetdrill on an unmodified kernel: after an active open, a segment
with SEG.ACK == ISS is silently accepted, where a passive open
answers with a challenge ACK.
Tested with the packetdrill tests added in the following patch,
which fail on the active side before this patch, and with the other
tests in tools/testing/selftests/net/packetdrill.
[1] https://mailarchive.ietf.org/arch/msg/tcpm/ZbjDTFQSHeKSVHAToyAnKBr3TpU/
Fixes: 3d501dd326fb ("tcp: do not accept ACK of bytes we never sent")
Reported-by: Flavius-Romeo Mazilu <flavius.mazilu@stud.acs.upb.ro>
Closes: https://mailarchive.ietf.org/arch/msg/tcpm/ym6lb-UkrW2298LRnTLxCysoo0g/
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
---
Documentation/networking/net_cachelines/tcp_sock.rst | 1 +
include/linux/tcp.h | 3 ++-
net/ipv4/tcp.c | 1 +
net/ipv4/tcp_input.c | 10 ++++++++--
4 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/Documentation/networking/net_cachelines/tcp_sock.rst b/Documentation/networking/net_cachelines/tcp_sock.rst
index 554e8c14a401f27ec5a6c109877bb122942bade9..78f74eb7699063022adc5d4524a82466c82e4758 100644
--- a/Documentation/networking/net_cachelines/tcp_sock.rst
+++ b/Documentation/networking/net_cachelines/tcp_sock.rst
@@ -59,6 +59,7 @@ u8:2 fastopen_client_fail
u8:4 nonagle read_write tcp_skb_entail,tcp_push_pending_frames
u8:1 thin_lto
u8:1 recvmsg_inq read_mostly tcp_recvmsg
+u8:1 bytes_acked_syn read_mostly tcp_ack
u8:1 repair read_mostly tcp_write_xmit
u8:1 frto
u8 repair_queue
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index e6b79cf4798f497ea43bb987431da2c797ee3086..13a192cc3c62e219235e0610924fe460148be19c 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -235,7 +235,8 @@ struct tcp_sock {
tcp_usec_ts : 1, /* TSval values in usec */
is_sack_reneg:1, /* in recovery from loss with SACK reneg? */
is_cwnd_limited:1,/* forward progress limited by snd_cwnd? */
- recvmsg_inq : 1;/* Indicate # of bytes in queue upon recvmsg */
+ recvmsg_inq : 1,/* Indicate # of bytes in queue upon recvmsg */
+ bytes_acked_syn:1;/* bytes_acked includes our SYN */
#ifdef CONFIG_BPF
u32 bpf_tcp_ops_flags;
#define BPF_TCP_OPS_TEST_FLAG(TP, ARG) \
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index d510e982dcea9830442d4c7afedb67deb3c28115..498889efe2e3323484b9d30842d9f16475165e4a 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3472,6 +3472,7 @@ int tcp_disconnect(struct sock *sk, int flags)
tp->segs_out = 0;
tp->bytes_sent = 0;
tp->bytes_acked = 0;
+ tp->bytes_acked_syn = 0;
tp->bytes_received = 0;
tp->bytes_retrans = 0;
tp->data_segs_in = 0;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index d35048c363be5cb985ba1efb9dab24c9aaab4fda..6cf6cb3336b23b065b93d747e0565475ce4c3d0c 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3712,6 +3712,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, const struct sk_buff *ack_skb,
} else {
flag |= FLAG_SYN_ACKED;
tp->retrans_stamp = 0;
+ /* tcp_snd_una_update() counted our SYN. */
+ tp->bytes_acked_syn = 1;
}
if (!fully_acked)
@@ -4333,8 +4335,12 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
if (before(ack, prior_snd_una)) {
u32 max_window;
- /* do not accept ACK for bytes we never sent. */
- max_window = min_t(u64, tp->max_window, tp->bytes_acked);
+ /* Do not accept ACK for bytes we never sent.
+ * Our SYN, if counted in bytes_acked, is not one of them:
+ * no valid ACK ever carried ISS.
+ */
+ max_window = min_t(u64, tp->max_window,
+ tp->bytes_acked - tp->bytes_acked_syn);
/* RFC 5961 5.2 [Blind Data Injection Attack].[Mitigation] */
if (before(ack, prior_snd_una - max_window)) {
if (!(flag & FLAG_NO_CHALLENGE_ACK))
--
2.53.0
Technical Details
Message-ID:
<20261118172654.1267071-2-edumazet@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366301-linux-kernel-netdev=dewy.ruReferences:
<20261118172654.1267071-1-edumazet@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366301-linux-kernel-netdev=dewy.ru From: edumazet@kernel.org (Eric Dumazet) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next 1/2] tcp: do not accept ACK of our ISS on active opens Date: Wed, 18 Nov 2026 18:26:53 +0100 Organization: Usenet Network Message-ID: <20261118172654.1267071-2-edumazet@kernel.org> References: <20261118172654.1267071-1-edumazet@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2651247"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:zR3jvWr+vLrR1RsGmdjPPKGo3LA= sha256:/sXz9NrAJdORBoH/qF1gsc4OtEzBbNkzeBkSrVa+bPE= sha1:7RUt7KbNBrrLzYn4bP5hJxZDbzQ= sha256:Bqt685EfykmIuHhxgVzVgPc905UA81OyWFw3r8Jc38w= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 6A1C5115348; Wed, 18 Nov 2026 20:28:52 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.5 X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zRFswqvqV-H7; Wed, 18 Nov 2026 20:28:48 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-366301-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 17D87115343; Wed, 18 Nov 2026 20:28:39 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id EAEAC627A75; Wed, 18 Nov 2026 17:28:27 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795022823; b=1o1U6afZ9UYCsDHMESUzRIkieDWdx6SPrsaGMkPgCJV4r1w/+wLotVr3Hsb/OPeiGLAF XKx92qBzwWtpTjncSAWeJz+9F78gynPreKuS7uui+wW0Wx8dP1+0mpJoP4As6bNXLJkHm gfbYeFpiQRInFA8E0C0cpfoMlVi3Yxf1W2bM6VKJw/Yd8ctnLUyQi6w25EZ5VOwHY0xFI 6EGfUFgAnjY6B4k2V9pMuQ9S45U9QOMEhgwS7zFlq8D5CTnH4ub1gZcGKEVNj4q7UAwVj r31PRlvKu372MGirDRLNt+0lzsxwGAC+G7bk2AebBaP8c+ioPJFib95crjL9Us+LnYg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795022823; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding; bh=GGhYkGebGexfGExsMQfltWE8JbYR5fBAohiVWSo1Fhk=; b=OdM8Hz15uAxCvIpwG+7IhOaDUPNSCSGbqEnXVdLRKwfTnheVHsw/ZipZwQqMZrxKxtdv vt6du4XmVJ+K4rX4JFhLHXfXFM/CBdXfd9EKx/X3oZpLa2NABkDPRpoWNJWo7XLtC/q30 YIG5RNrYXXQcPLomL+Xcr2WhnH9d5oVPrhH6vMOGgeNkjBwpSCU+FwlYe+YivplhQMl1G YDovynSigotsQ6NU/M4G4EY6SqPdKQKb8UIo3BGDcN+XJH6QtJxV4vCAx1fScaorNqESu 8zzydCtOfpAlnME4sQB25AnvaUP5wZIRKeJn8UDQ8kWP1eEZrY1zX+iZMu9M1gqm0uQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fHELRVvR; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B127606A774; Wed, 18 Nov 2026 17:27:03 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fHELRVvR X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795022822; b=2GleQL5GxIXm8q0VFQPUtPbdBRBWyIS59A28kS2KNl6SdpsWm25ao8I0h1cl9b87D+vr ONH/f4o3vBp1gArvj3946oJ+8Gi9ju+Tvq+ro/jZqOb/UlbWT/9YxZy/7FjEhMmKTwXCp lSYk3eVfNx+i3QQkuYGz08i1hisY21xud856i/x3Mg6TSrGl0MgDB0ZlViFqWm4XSTbao Kz++OJ8pAvrGMZimAXPqriDf+iutAZrgpv6f1s57ElOtuQlYgO1MXzFeuMzBFWD/ii4gE qAC1drrEMcpWnD4zNsUWinwavydFiJCL1ldNh7OpaaBQAvRId8nbpKnzsCiIsMqkJlw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795022822; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=GGhYkGebGexfGExsMQfltWE8JbYR5fBAohiVWSo1Fhk=; b=AWGqRlVriES/wjdi/HJbRxiD6rNHBUK8N0UQf4hTh5byfjk/L1faz1kCqcNX+g8SIJ2W y0CeFquQwgHEbu8P5nU7vSGvsemwAVI+0Tccz9eUXuLAHfTc+PxioY1ylQayN5PfRdHV3 1odyMFTW8kOu9Jb7Vbwxa9DrxrBvjl7vikYJamMTUtdtOpZzgu5oz8wjv/HLbo9FnkxZz 732FF94/XwKEwPkeY+OWNwISnOEfautWngn1Q6ztWyzX0PoEdbInyCt/7Bn1TIBCpRKMP thlrf2jdXjrL+aYiLH0Kdab6hcsUrs3XcJsL+elHyUVpMyhrkoa1ZI41XIY6w8G+5Og== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fHELRVvR; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABC30606A76D for <netdev@vger.kernel.org>; Wed, 18 Nov 2026 17:27:02 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A1DE1F000C4; Wed, 18 Nov 2026 17:27:00 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795022822; bh=GGhYkGebGexfGExsMQfltWE8JbYR5fBAohiVWSo1Fhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fHELRVvReToQfCU9wVfxnSZjVjwAg0qwC7egXwtHFFz+CFACnYx+udxlmCi3YRBKx jMrihPHbShQyXJId5QwIvTsOCI2xKlfYKrOaXuPELI7mUjIBzwPfrBrxy+TwzpM1qL 4cR7VIlfDrXkKwzrmV7EV9ZKNrF4+FTgKBLqyw3ND81K4FSzcosbAIfO9MmMtI2rOV Ardk7kKWIIxf8lc/YQvER0px3JH7HSTY7ZNq3VXw2c2PaeQDU7RVD3Ak5uhVjRo5xx QHNFFKKNutw1DF57DPvF4yyyU6BBxy4S1RR6Myv3pebCkMidTa2HTPF7+sWe0uoBtY hy6ZAQINFiXwA== X-Cc: Kuniyuki Iwashima <kuniyu@google.com>, Simon Horman <horms@kernel.org>, Flavius-Romeo Mazilu <flavius.mazilu@stud.acs.upb.ro>, Michael Tuexen <tuexen@fh-muenster.de>, netdev@vger.kernel.org, Eric Dumazet <edumazet@kernel.org> X-Mailer: git-send-email 2.53.0 X-In-Reply-To: <20261118172654.1267071-1-edumazet@kernel.org> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list