Article View: linux.kernel.netdev
Article #16780Re: [PATCH net] tcp: purge Fast Open RST queue when listen() fails
From: netdev-bot+sashiko
Date: Sun, 15 Nov 2026 21:17
Date: Sun, 15 Nov 2026 21:17
109 lines
11644 bytes
11644 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The fix is incomplete.
--
tcp: purge Fast Open RST queue when listen() fails
This patch moves the rskq_rst_head purge out of inet_csk_listen_stop()
into a new helper, reqsk_fastopen_purge_rst(). It also calls that helper
from the inet_csk_listen_start() error path, after the socket has been
set back to TCP_CLOSE. The goal is to reclaim Fast Open request_socks
that were queued while the socket was briefly in TCP_LISTEN.
Closes: https://lore.kernel.org/netdev/179450310167.2199510.18107423940014989443@kernel.org/
> diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
> index ca3057192e6da..c33b0095468af 100644
> --- a/net/ipv4/inet_connection_sock.c
> +++ b/net/ipv4/inet_connection_sock.c
[ ... ]
> @@ -1373,6 +1389,12 @@ int inet_csk_listen_start(struct sock *sk)
> }
>
> inet_sk_set_state(sk, TCP_CLOSE);
> +
> + /* A Fast Open child accepted before a previous shutdown() of this
> + * listener might have queued its request in rskq_rst_head while
> + * we were transiently in TCP_LISTEN state.
> + */
> + reqsk_fastopen_purge_rst(&icsk->icsk_accept_queue);
> return err;
> }
[Severity: High]
Does this error path also need to drain rskq_accept_head?
The commit message says the socket goes back to TCP_CLOSE "without going
through inet_csk_listen_stop()". This path only cleans up rskq_rst_head,
but the accept queue can be filled during the same TCP_LISTEN window.
After shutdown(SHUT_RD) or connect(AF_UNSPEC), inet_csk_listen_stop()
drains the accept queue. TCP_NEW_SYN_RECV request_socks still stay in
ehash with rsk_listener pointing at this socket, until
reqsk_timer_handler() drops them.
Suppose listen() is called again, and the peer's final ACK for one of
those requests arrives while sk_state is TCP_LISTEN:
tcp_v4_rcv()
if (unlikely(sk->sk_state != TCP_LISTEN)) <- not taken
tcp_check_req() <- no listener re-check
tcp_v4_syn_recv_sock()
inet_csk_complete_hashdance()
inet_csk_reqsk_queue_add()
Under rskq_lock, inet_csk_reqsk_queue_add() still sees TCP_LISTEN and
queues the child:
} else {
req->sk = child;
req->dl_next = NULL;
...
queue->rskq_accept_tail = req;
sk_acceptq_added(sk);
}
__inet_inherit_port() can succeed here when the port was locked by an
explicit bind(). That is also the setup of the -EADDRINUSE example in
the commit message.
If get_port() or hash() then fails, the socket returns to TCP_CLOSE. The
req and child are still on rskq_accept_head, and sk_ack_backlog is not
zero.
Nothing seems to reclaim them after that:
- inet_csk_accept() rejects sockets that are not listening.
- __tcp_close(), tcp_disconnect() and tcp_abort() only call
inet_csk_listen_stop() from TCP_LISTEN.
- A later successful listen() overwrites rskq_accept_head and resets
sk_ack_backlog in reqsk_queue_alloc().
Wouldn't this leak the established child socket, its request_sock, and
the listener reference held through rsk_listener? That is the same kind
of leak this patch fixes for rskq_rst_head.
Could the error path run the full inet_csk_listen_stop() cleanup after
setting TCP_CLOSE? Alternatively, could TCP_LISTEN be set only after
get_port() and hash() succeed?
[ ... ]
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261114111247.21995-1-edumazet%40kernel.org
Technical Details
Message-ID:
<179477744662.3136.16061867603109307859@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363857-linux-kernel-netdev=dewy.ruReferences:
<20261114111247.21995-1-edumazet@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363857-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] tcp: purge Fast Open RST queue when listen() fails Date: Sun, 15 Nov 2026 21:17:26 +0000 Organization: Usenet Network Message-ID: <179477744662.3136.16061867603109307859@kernel.org> References: <20261114111247.21995-1-edumazet@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1900487"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:w48WPJUWFB2sUV771Xj+FEHBdyY= sha256:8s5xWDzIBmQRQPd+96i+z4TcKxYqBVIaOeRdzakGBz4= sha1:6LHdHRiRpmQnKl/Od35h6ve2rDY= sha256:5wYzGQDLoi4K255W20Iy2/0LapNOAiNlVZYoSzQteF0= 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 5165F114A6F; Mon, 16 Nov 2026 00:17:44 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, 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] 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 V_-Y06G2hrFS; Mon, 16 Nov 2026 00:17:40 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-363857-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 433E5114A68; Mon, 16 Nov 2026 00:17:31 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 2F717375B5; Sun, 15 Nov 2026 21:17:29 +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=1794777448; b=gJnRauKq2zUyp999laqtshdIzuDhUXwzCpB487D5bSW+cQR0csJkIL/5ZOMI0vvhWn/f qPAmzxLsT/cHR5UnbdNJA8MZVF+XlOOqeu2dTFB/Lw8votB+zZgF90cSyG5yZVACOlx1P FN/9XFRAp7XzD55wYUDhMfhmEBbgHBqkfmsVTajJG3/h3I52KnVfFC0/Q0kcqE8VM0czk CixpY2wQNCCnE/yA32AcvOxMjFp2Hpr5NcE25DbxfgDa7vNqNkovFVu1MXqWee5WJuNXG ODmSuHEwwUHy+Uz4z8HIXfTdQc5e/Q0TkidBeRP0aln59eS1rN+0Cg0n1fDORC2isIw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794777448; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=/i8ZOAiepp/PGkORWIRG6O/6WCcMM+wyJ+tB43yNBv4=; b=HjD/34l8wfyW/MXdz+b//oIB5bjoly0eugPIrE9h8VgtC2CkC+mFf7hsANiOfqgIxx6a OqeqsvBNUOa7HISFVBD9p67DV7BhQ76lHN+uqUAgLX5QzAmoRcqHSZgKl6nRIMONkjzoM 37BOTBJG1HjtUHE+NsggYJ8WCkk66f+OLfKEdgWAvKU7NeoJbZqhzLyAeynP4ubQ3g1JY /aXYMGdSqLYrQO1TqAs+9BJ0E0ZXTxuMMlwVvbb10USMXMJsLjSpzIfZ7UsNLgkFvkQfM 2+1LUufWkvkw7CnC1AEjKVFYBkNaByGpUHgmt7knsmoWGi2RLoY94lqIaLS86reFASA== 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=OoEek1Ji; 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 D2BDE606A331; Sun, 15 Nov 2026 21:17:28 +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=OoEek1Ji 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=1794777448; b=07DWeIYT8ybBNp6Sixs+hJNenXpSMfDIZeyUaX56u363E6eG6KZvcHzp5KDdZ7rrmPeG QbdYoofEu7NUwo+HeOnRAit1q8x5rh9o2QjQ91BASqTafmh4AQNyKXCX4HDSB11GYJ8TN VtcbrCrOOXbjUEhpJCxfLnBp/O1C18IjoE/8n+7q9VX9abqbw6ib1zMivMRfbKWVYsK96 XdM3o2U8OiDUYwOepE/dTOSTVrLYP6oQVZZGagS2mxK+Jzlg0aUw1UwqqYW/tHrmJHUZ3 suuyxvK5rTcaEuSGA6bpNbYyOOnWU2tvaVbcGBZkjT0+/pyOzN2pNEA//ZDwH96cO3Q== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794777448; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=/i8ZOAiepp/PGkORWIRG6O/6WCcMM+wyJ+tB43yNBv4=; b=vGSUUnqn59WMrt+SGfmuVZ2RcRVh9ROstJaq8nF0RcHixcQcOcyJmVbypYZGtMr/RIlq CYQOz1fYfkKDlHsEaL67PtzJV3n47IJQ8ldIC5nOqQxGhAn5BNRQAdWf7bTULmPbkenl1 AxDqMTLY0tM6XShsHAEL76hSuKtSNnX7MakgxkOTEhWKOaU9lXfxzQg9akp1PCXuu+4oO PyDVldIYgeG8MqsXunikYFRW9nZ1Nspn1UYX85xRl2g68hQQhrnVRWzGKJQgbOki+QjxM 5VzJSB+TW8fa0pA0jwvnexX8qMpdO5pMNjYLX11+Q02/edEBSW1r+XD/9wnnRx/KEtA== 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=OoEek1Ji; 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 F12CE606A31F for <netdev@vger.kernel.org>; Sun, 15 Nov 2026 21:17:27 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18E5F1F000C5; Sun, 15 Nov 2026 21:17:27 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794777447; bh=/i8ZOAiepp/PGkORWIRG6O/6WCcMM+wyJ+tB43yNBv4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=OoEek1Ji3J5ZCRoicmQ0jnPzhM48dkfNodJn6daW1hsE21DBxzOTjyYe8iB7UVEkG IOhB7SURt7d0ZsMRQcwYIU9n3koUGB9HfbKB2NZRfe265lfNxo7bwfvrNhfYkv6tR7 +G6Avv/iBWcu0TU6yrzig6Gt0L5QAV/ua7hDLwBpsDfw2A2o2JLm7z6enqz4+rLQ12 h7FLD3iiGM11+wWF5DOddZKGAPWi8ah6ZKuAmeupOKAnoTVZ8mtcEftidLJQj/K1ZA aO8l8OjNZJIuxwK1oREwxmwdk+J/uxlKjss25y9m/AJjteuXtmT3YRSYF11oSgyBdF ftvHwYLsdTIAA== X-Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, kuniyu@google.com, ncardwell@google.com, horms@kernel.org, netdev@vger.kernel.org, netdev-bot+sashiko@kernel.org, imv4bel@gmail.com X-In-Reply-To: <20261114111247.21995-1-edumazet@kernel.org> X-sashiko-severity: High 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