🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #22500

[PATCH net] tcp: fix spurious RST when SYN_RECV race is lost

#22500
From: Jiayuan Chen
Date: Wed, 25 Nov 2026 12:46
54 lines
10019 bytes
When the last ACK of 3WHS and the first data packet are processed on
different cpus, both can find the same req. The winner creates the
child and adds it to the accept queue. If this makes the accept queue
full, syn_recv_sock() fails for the loser and tcp_check_req() sends a
RST when tcp_abort_on_overflow is set. Only after that it finds the
req was stolen, and the packet is fed to the child.

The client gets a RST for a connection the server has accepted, and
the server application can even read the data.

Drop the req first, and do not send the RST if another cpu already
took it.

Fixes: 079096f103fa ("tcp/dccp: install syn_recv requests into ehash table")
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
---
 net/ipv4/tcp_minisocks.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index a05bb02e204c..934012cdac27 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -962,6 +962,13 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
 	}
 
 embryonic_reset:
+	if (!fastopen) {
+		if (!inet_csk_reqsk_queue_drop(req->rsk_listener, req)) {
+			*req_stolen = true;
+			return NULL;
+		}
+		__NET_INC_STATS(sock_net(sk), LINUX_MIB_EMBRYONICRSTS);
+	}
 	if (!(flg & TCP_FLAG_RST)) {
 		/* Received a bad SYN pkt - for TFO We try not to reset
 		 * the local connection unless it's really necessary to
@@ -973,13 +980,6 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
 		reqsk_fastopen_remove(sk, req, true);
 		tcp_reset(sk, skb);
 	}
-	if (!fastopen) {
-		bool unlinked = inet_csk_reqsk_queue_drop(req->rsk_listener, req);
-
-		if (unlinked)
-			__NET_INC_STATS(sock_net(sk), LINUX_MIB_EMBRYONICRSTS);
-		*req_stolen = !unlinked;
-	}
 	return NULL;
 }
 
-- 
2.43.0
Technical Details
Message-ID: <20261125124653.289409-1-jiayuan.chen@linux.dev>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371315-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371315-linux-kernel-netdev=dewy.ru
From: jiayuan.chen@linux.dev (Jiayuan Chen)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] tcp: fix spurious RST when SYN_RECV race is lost
Date: Wed, 25 Nov 2026 20:46:52 +0800
Organization: Usenet Network
Message-ID: <20261125124653.289409-1-jiayuan.chen@linux.dev>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="206711"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:UNaj/l32Q7fUfiMsF+IlABKBBc0= sha256:YqlrqzQKBDxxsPyKjJExy8bV8/ZxU5pvCuFpXSt8ZLs=
	sha1:jqIHoZy1teSRjIK8jp10Hvu/UMA= sha256:I52J9b6WyPxJCP+gxd070UJllWAwGNMXIW3EE+OwtvQ=
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 E2E38125E67; Wed, 25 Nov 2026 15:47:25 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.05
X-Spam-Status: No, score=-2.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	HK_RANDOM_FROM=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 (1024-bit key)
	header.d=linux.dev
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 b1nk312frCdf;
	Wed, 25 Nov 2026 15:47:22 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-371315-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 55484125E65; Wed, 25 Nov 2026 15:47:14 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 841313C5CC; Wed, 25 Nov 2026 12:47:09 +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=1795610825;
	b=uT0QAH9fOtKn9gtJXwhkDkw+Pjbjmns0fRQH6LR2oiStARZuHwqM/dAW7jcGRPPLkFea
	 ZT/30qBYbv4MRDwwwsPdJPvpoCSSj1Nj2uZ4h4dJPtAl13/i2LmP7bYOJu/fMCjRK2JAb
	 DL/6C+LPGsMCsnnTCZEWGh0U5CBHG/zcx0GT0mnwm9lOraknGBUr4H2skp78owE6PhMNl
	 QEWqKSCd/h3g3PsioTK7zsMYXFFdXG9kFzAKCLX+8jmceip35DbY97u+UrOsK8r76QbVb
	 ERQ+q3pDRmOqwENXuO2rgbP4/wmGE5OFKIUrPvNP20Z9HR+u9G9hQmuxZ8mOaDwpVcQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795610825;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:
	 Subject:Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Transfer-Encoding;
	bh=WKLeq57PGDEd4HRLeQ29cPTv5WJHJlL5Kr8i80uht18=;
	b=kOdkDu8z9kbYCL7aKFVWpxxnIQEIo8LPpSljWQBwFDfCAjfJEtbkkJnB39ur9UfEu8UT
	 SQ3134dqZs/TLmM1vhPsRCbMGbXkJXUSRnko9m8b/j6ynFWZ8Z2lF7J9WymkrhII9AX4D
	 Y641Hon/Qa3L1v7CSUtuFqRmukCdSTKczzsG+Xzj78mS18Dmzzo7H0Blkrp4xGl3slWSh
	 BS/XRd8rPIKhnue2z5Ws/TR0+JnR+PRLaCbDsEVgt2C8qx2BsLQeMXkgjEy8MM237J0so
	 5hYCqkDmGw8lpL4+z7Eo/85fdy/4YnCyusdhrXS/DLkKe/Nel0AP6FY72Wdveeb8Q3w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=C4pghcHR;
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	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 B50BE606A68F;
	Wed, 25 Nov 2026 12:47:05 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=C4pghcHR
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.116
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795610824;
	b=EBvr6S00GtctPl0Vk6GHV8wN+xW8il1OKY2kXDsXZBAwHXYnhk7dM2JynOVKrmi+mGFT
	 yRImY7tFSORYRFGP/IkMjHDB8MERY6gylso1vqrNO6ykqPL7EP8Xd3H+Cir8W/VwveWXQ
	 xegXxy87PhHB1TXrbzoxdgOU9To2atOS4Ul/q+oNOPTbETH0KKTS2wc9458eaAPga8beZ
	 fg4HpReUshNYy5gRUcpDZvEx/c4nvCMnigerVF401kSrSU4ts1Kx9e3TaJJnK8m+w+Grx
	 /p7kQw6nE9AQPMuNEvwxDSYjlPr9mpaIaEa5+kg6U6U36WKdip4yLa1iQE6bWJydN7w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795610824;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID:
	 X-Mailer:MIME-Version:Content-Transfer-Encoding;
	bh=WKLeq57PGDEd4HRLeQ29cPTv5WJHJlL5Kr8i80uht18=;
	b=Skn7oODFbjSD9P1dvrklToPdJRtsEYE5qZ3MR8ngCiIA+wplVn+nWyG882rxxSwXuYPo
	 5X4u0FPeG2oBTrdfoCJJfhVfuP91J6gsE5xOAsaWAOKv0UDdGE3lPBsCAMp8Lk5hyBfqV
	 y78DXA/Spydpzs+wEOk0+9ZYRESc1DshZ6IybKKfmkxFu8TpbBeBUg/aE1A/YGkbnodkY
	 TH92FDvAnBGWPB98+eKq95v5/6zL8Fwy6ciFcyaYd02HUFLSX5J1ogkPmq6S2MEsAPGO+
	 mk6zxtQXKGqkjSE3D2/K1R3WrnwHv6irRF34pirMTKhLCOT3vAWD8EH6IzstD44yLPw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=C4pghcHR;
	arc=none smtp.remote-ip=95.215.58.116
X-Received: from mta1.migadu.com (out-116.mta1.migadu.com [95.215.58.116])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 060CB606A334
	for <netdev@vger.kernel.org>; Wed, 25 Nov 2026 12:47:03 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 060CB606A334
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=7N2mG8hlwARmTvtTPVydpG6bDGyyYoQuvvnSGfm7Oj4=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1795610822; v=1; x=1796215622;
 b=C4pghcHRtOYdeqwJdQetTAvZDL8u+Y4noydJZrICsXOTBw0VPM9rsXdTwwLlZ+HTXUXLZb+a
 4C7V9qgUz7RIMcoWS6knUAVwjnEOxUq2BnkGYO8herkShszn5dWnrHt/i64Rif3SGmqSQZlI9zq
 Kanf5zc0zbOJqq+AN7huvMnU=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by smtp.migadu.com with ESMTPS id 7027d17222310f08;
	Wed, 25 Nov 2026 12:47:01 +0000
X-Mizu-Trace-ID: 7027d17222310f08
X-Migadu-Flow: FLOW_OUT
X-Cc: Jiayuan Chen <jiayuan.chen@linux.dev>,
	Eric Dumazet <edumazet@kernel.org>,
	Neal Cardwell <ncardwell@google.com>,
	Kuniyuki Iwashima <kuniyu@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.43.0
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