Article View: linux.kernel.netdev
Article #15303Re: [PATCH net v2] tcp: fix NULL pointer dereference when restarting a Fast Open listener
From: netdev-bot+sashiko
Date: Thu, 12 Nov 2026 17:05
Date: Thu, 12 Nov 2026 17:05
113 lines
11879 bytes
11879 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 patch is meant to stop request_socks from being stranded in
rskq_rst_head while they hold a listener reference, but another path…
--
tcp: fix NULL pointer dereference when restarting a Fast Open listener
This patch makes inet_csk_listen_stop() always take fastopenq.lock and
detach rskq_rst_head while holding it. That serializes the drain against
reqsk_fastopen_remove() adding entries to the RST list. The goal is to
stop request_socks from being stranded on rskq_rst_head while holding a
listener reference, and to avoid the NULL rskq_rst_tail dereference seen
when listen() is called again.
> diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
> index 37cc8606d6835..9ca59dca5d184 100644
> --- a/net/ipv4/inet_connection_sock.c
> +++ b/net/ipv4/inet_connection_sock.c
> @@ -1533,17 +1533,15 @@ void inet_csk_listen_stop(struct sock *sk)
[ ... ]
> + /* Free all the reqs queued in rskq_rst_head. */
> + spin_lock_bh(&queue->fastopenq.lock);
> + req = queue->fastopenq.rskq_rst_head;
> + queue->fastopenq.rskq_rst_head = NULL;
> + spin_unlock_bh(&queue->fastopenq.lock);
> + while (req != NULL) {
> + next = req->dl_next;
> + reqsk_put(req);
> + req = next;
> }
> WARN_ON_ONCE(sk->sk_ack_backlog);
> }
[Severity: High]
Is this fix complete? The commit message says:
With this synchronization, reqsk_fastopen_remove() either inserts the
request_sock before inet_csk_listen_stop() acquires the lock, in which
case inet_csk_listen_stop() reclaims it, or sees that the listener is
not in TCP_LISTEN and does not insert anything.
That argument only holds if every exit from TCP_LISTEN goes through
inet_csk_listen_stop(). The failure path in inet_csk_listen_start()
does not:
net/ipv4/inet_connection_sock.c:inet_csk_listen_start() {
...
reqsk_queue_alloc(&icsk->icsk_accept_queue);
...
inet_sk_state_store(sk, TCP_LISTEN);
err = sk->sk_prot->get_port(sk, inet->inet_num);
if (!err) {
...
err = sk->sk_prot->hash(sk);
if (likely(!err))
return 0;
}
inet_sk_set_state(sk, TCP_CLOSE);
return err;
}
Take a listener that went through shutdown(SHUT_RD) or connect(AF_UNSPEC)
while an accepted Fast Open child was still in SYN_RECV. Then listen() is
called on it again. If an RST for that child arrives after TCP_LISTEN is
stored, reqsk_fastopen_remove() passes this check under fastopenq->lock:
if (!reset || lsk->sk_state != TCP_LISTEN) {
It then links req onto rskq_rst_head/rskq_rst_tail without calling
reqsk_put().
Now suppose get_port() fails afterwards, for example with EADDRINUSE
because another SO_REUSEADDR socket started listening on the port, or
hash() fails. The socket goes back to TCP_CLOSE and rskq_rst_head is never
drained.
A later close() will not reclaim the list, because __tcp_close() only
calls inet_csk_listen_stop() when sk_state == TCP_LISTEN. A later
successful listen() just overwrites the list in reqsk_queue_alloc():
queue->fastopenq.rskq_rst_head = NULL;
queue->fastopenq.rskq_rst_tail = NULL;
Does this leak the request_sock? If so, it also leaks the listener
reference taken in reqsk_alloc_noprof(), which only
sock_put(req->rsk_listener) in __reqsk_free() drops. That would pin the
listener sock and its netns reference too.
This looks like the same leak the commit message describes, reached
through a different TCP_LISTEN -> TCP_CLOSE transition.
Should the inet_csk_listen_start() error path also drain fastopenq under
fastopenq.lock? Alternatively, could the drain move to a place that covers
both paths?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/avMkfJrXhCFXn8M_%40v4bel
Technical Details
Message-ID:
<179450310167.2199510.18107423940014989443@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362035-linux-kernel-netdev=dewy.ruReferences:
<avMkfJrXhCFXn8M_@v4bel>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362035-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2] tcp: fix NULL pointer dereference when restarting a Fast Open listener Date: Thu, 12 Nov 2026 17:05:01 +0000 Organization: Usenet Network Message-ID: <179450310167.2199510.18107423940014989443@kernel.org> References: <avMkfJrXhCFXn8M_@v4bel> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1132107"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:c6MJFBHgaU+upgDk9cReUHNW1vQ= sha256:hdRPn+Hnn3dwHJ9l7ic1EPgz5HmwBGpVkGnfmGhpf74= sha1:UsIGNzqV0Pm1Igd1pxCm/f+NARc= sha256:Gqtf5vAJhOQHUoTb5lIZ4lD6cqE55aQpp3HKOShSNK8= 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 27E0E11430A; Thu, 12 Nov 2026 20:11:52 +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 D501WP7EXAsf; Thu, 12 Nov 2026 20:11:46 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-362035-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id F0682114307; Thu, 12 Nov 2026 20:11:37 +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 ECC9B64449; Thu, 12 Nov 2026 17:05:04 +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=1794503103; b=DKQEw2wOn4NFwJFYfhAJNkw+umBuX3GcbU3xklCRCVULhXpf/J316WvIMOYnk/ElRtsO Iu4Vo9WxQfkk/40uW4Frgn7DsN7epzC7u9O7QOPcRupuH1GJmXFV+mH9b9x9Z2Q92GOiV 6RZHAbAp4GB15bjTv1kHw4s1FQVqmYpatY44I8+7XVbyqywevNAd984+j02fxlPZydxPO dfYCuSette+bF9Oz2RLfP8D/RKJMRaVDncnEuAi3vDRnbL0GTlubTwzf9Xvo9U15j01im FNteh094kb91sKBFcGusVaGWu8mypAMbg6hc//otzPfkzpvl7aAcBKD6uBj51eqlgiw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794503103; 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=wbD8bqsyj1FI3svUFeCRQnTnpsoTV5729OFTLNVeQsY=; b=JkYEkpcAK1RFb86OXpEaT9CIlQ2XG0qJmWD2H9FxJApxV4lJ2cj4MLTB5dsRVTrm7zI7 5NDTnThYXTrtHIgob0amuW1lo1MzEHTCeunmEdfR8ufuWO+yHnCQxGKMiEMPQ8DCaDfk5 csKr4zfriuKvS7ptKt/kS22MhOd+CrOjFkPA2Tz4HX6JsvtGG3B7cajrQmgOMHIF8OToG 5Vf8FgkFaGDLEp92DgNMUwHgUaaJds1t8ncja3eumG0qbMismfd7RS47ThDdj7LW2FRhS GaIqIDdWZbjYKXB3/8XmrMVcd1KW0+3/RHVTMxMgPXKDXq0Y8JNNMpCH1J/n9DA3+aA== 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=Eo0mCFUq; 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 D2FE1606A331; Thu, 12 Nov 2026 17:05: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=Eo0mCFUq 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=1794503103; b=aOA0cLzM0DsVoth8zCBPU7YheYm8kAludlz4Sk3tXCkmmqYYHAddRjdE+9hwNeZRJjbo mtB0by+hO6NPpMzoz4r3Rw0vDoajIQfGSdc8A2a/wxOaES+87kVpLfF6Ng9WCPgZPUlMw viB6LzpSNyvQ+xMFkQmeleJViQalch9Sy22rJENtzAntYYBWoyb95ehmYf42TOENrOojW USgjkrJm1oPQQYbq8ZSHm5lBpIss9pfvfXDetrTKCfQtk97YnLN+AZRCPWdPZrezarL6Q q/rZoS17vtxRT0TQ7ZPlB68qKLt6eu/nG8EkioP3xeI7XrjkgVb4F1xUCN354oJoq+w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794503103; 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=wbD8bqsyj1FI3svUFeCRQnTnpsoTV5729OFTLNVeQsY=; b=VzXRGqr9dWGizGhKri0FpKkwLBQhUVy0Yb7I1TIEZ0qlzowO8/FfL/FySUmmmMrAi0su KinuY2pQK9T+k2g/pqZiTJ33LY3GVhgPkQqWtxgN/vjylldGHz2XCevXCE7zqurVd6GLn 2ck3Gjof/mYv+A+RruwS8gocOJ1bZETtc+dNn7eW45cRr5RhUP7iAy08nMlaENXgyjrMb 7a0NeiWOeaf0GhaYRAs/0LajliPsOJZbeJ7tIS1bftw82fOxpc41mP+Sh27XLhM37mZgW eL7rMqRr8m+225tIUCnmyqO1TxpSDzAwvhRrnjlET9Ic5LRkRyuuM5ycHCL1WkOvKWQ== 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=Eo0mCFUq; 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 EBE27606A323 for <netdev@vger.kernel.org>; Thu, 12 Nov 2026 17:05:02 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B5861F000C4; Thu, 12 Nov 2026 17:05:02 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794503102; bh=wbD8bqsyj1FI3svUFeCRQnTnpsoTV5729OFTLNVeQsY=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Eo0mCFUqVCu8SqQKARkPAwg+JYn+9QI1QclpjdFj3lLoo7qTygDTkm4gdFXvkG6dN bcdpYfJRs5psWen+iJII0FxlvH0Dmv1KenwfJtmNb4glp5KpSEXJGcPmbV4Kh+xeY7 aP5r9dA9uAnLG5rNc55Wv8U8m//G9dltyIHJo8PU/ZRiYHOtpI5SkIQmOsFUry6F72 7fG9hNE8EZNHlo2kCMMoWOEsb6tk299gy6NSaQMYsdMKLAqPC3Tm/8kYlTLEsOAHJl 8dm6J3G6hXDK+pp+3NE1D6BmTm5AWymiGrq8kmLZ0GTnVIIEX4pi6tqFFzTAlAkF/b /VTczqs9SvTWw== X-Cc: edumazet@kernel.org, ncardwell@google.com, kuniyu@google.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org X-In-Reply-To: <avMkfJrXhCFXn8M_@v4bel> 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