All of lore.kernel.org
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: matttbe@kernel.org
Cc: mptcp@lists.linux.dev, mason@kernel.org, pabeni@redhat.com,
	kuba@kernel.org
Subject: Re: [PATCH mptcp-net 01/34] tcp: drain the queues of a listen() that fails
Date: Sun, 15 Nov 2026 10:53:05 +0000	[thread overview]
Message-ID: <179473998528.488855.7816958320444264036@kernel.org> (raw)
In-Reply-To: <20261113-mptcp-cmason-fixes-v1-1-9205b77e9a2f@kernel.org>

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 new error-path drain in inet_csk_listen_start() can still
  miss an RST-queue entry, so the TFO leak this commit says it closes…

--

tcp: drain the queues of a listen() that fails

This patch changes the error path of inet_csk_listen_start() to call
inet_csk_listen_stop() after it sets TCP_CLOSE again. Children and TFO
RST-queue entries that reqs from an earlier listen() add during the
temporary TCP_LISTEN window are then freed. MPTCP subflows are skipped
here and left to mptcp_listen(), which a following patch handles.

> diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
> index 5807067083c90..3d9cc189c8075 100644
> --- a/net/ipv4/inet_connection_sock.c
> +++ b/net/ipv4/inet_connection_sock.c

[ ... ]

> @@ -1371,6 +1371,10 @@ int inet_csk_listen_start(struct sock *sk)
>  	}
>  
>  	inet_sk_set_state(sk, TCP_CLOSE);
> +
> +	/* MPTCP subflows are drained by mptcp_listen() */
> +	if (!sk_is_mptcp(sk))
> +		inet_csk_listen_stop(sk);

[Severity: High]
Can this new drain still miss an entry on the TFO RST queue?

inet_csk_listen_stop() checks whether to drain the RST queue without
taking fastopenq.lock:

net/ipv4/inet_connection_sock.c:inet_csk_listen_stop() {
    ...
	if (queue->fastopenq.rskq_rst_head) {
		/* Free all the reqs queued in rskq_rst_head. */
		spin_lock_bh(&queue->fastopenq.lock);
    ...
}

The writer is reqsk_fastopen_remove(). tcp_check_req() calls it when an
accepted TFO child in SYN_RECV receives a valid RST. It runs in the
child's context and holds only fastopenq->lock:

net/ipv4/tcp_fastopen.c:reqsk_fastopen_remove() {
    ...
	spin_lock_bh(&fastopenq->lock);
    ...
	if (!reset || lsk->sk_state != TCP_LISTEN) {
    ...
	if (fastopenq->rskq_rst_head == NULL)
		fastopenq->rskq_rst_head = req;
	else
		fastopenq->rskq_rst_tail->dl_next = req;
    ...
	spin_unlock_bh(&fastopenq->lock);
}

Is this interleaving possible?

CPU0 (failing listen())            CPU1 (child receives RST)
inet_sk_state_store(TCP_LISTEN)
                                   tcp_check_req()
                                     reqsk_fastopen_remove(sk, req, true)
                                       spin_lock_bh(&fastopenq->lock)
                                       sees lsk->sk_state == TCP_LISTEN
get_port() fails
inet_sk_set_state(TCP_CLOSE)
inet_csk_listen_stop()
  accept queue loop (rskq_lock only)
  reads rskq_rst_head == NULL,
  skips the drain
                                       fastopenq->rskq_rst_head = req
                                       spin_unlock_bh(&fastopenq->lock)

After that, nothing frees the req. close() drains the queues only in
TCP_LISTEN. The next listen() calls reqsk_queue_alloc(), which sets
rskq_rst_head and rskq_rst_tail to NULL.

The req holds a reference on req->rsk_listener. The listener socket and
its netns would then stay pinned, which is the same leak the commit
message describes.

The accept queue does not appear to have this problem, because
inet_csk_reqsk_queue_add() and reqsk_queue_remove() both run under
rskq_lock. The MPTCP error path added by "mptcp: drain the queues of a
listen() that fails" calls the same inet_csk_listen_stop(), so it seems
to have the same race.

Could inet_csk_listen_stop() drop the lockless pre-check and instead read
and clear rskq_rst_head under spin_lock_bh(&queue->fastopenq.lock)?

TCP_CLOSE is stored before that lock is taken. A reqsk_fastopen_remove()
that took the lock first would have its insertion seen and freed by the
drain. One that takes the lock later would see TCP_CLOSE and call
reqsk_put() itself.

>  	return err;
>  }

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-mptcp-cmason-fixes-v1-0-9205b77e9a2f%40kernel.org

  reply	other threads:[~2026-11-15 10:53 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 19:53 [PATCH mptcp-net 00/34] mptcp: misc fixes Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 01/34] tcp: drain the queues of a listen() that fails Matthieu Baerts (NGI0)
2026-11-15 10:53   ` netdev-bot+sashiko [this message]
2026-11-13 19:53 ` [PATCH mptcp-net 02/34] mptcp: " Matthieu Baerts (NGI0)
2026-11-13 20:13   ` sashiko-bot
2026-11-13 19:53 ` [PATCH mptcp-net 03/34] mptcp: clear inet_opt in the child of an IPv6 listener Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 04/34] mptcp: pm: work on a copy of the received RM_ADDR list Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 05/34] mptcp: pm: don't drop an RM_ADDR behind a pending one Matthieu Baerts (NGI0)
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:53 ` [PATCH mptcp-net 06/34] mptcp: pm: don't drop an RM_ADDR because of an ADD_ADDR Matthieu Baerts (NGI0)
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:53 ` [PATCH mptcp-net 07/34] mptcp: arm the rtx timer if a push leaves data behind Matthieu Baerts (NGI0)
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:53 ` [PATCH mptcp-net 08/34] mptcp: force the charge for the first skb of a subflow Matthieu Baerts (NGI0)
2026-11-13 20:09   ` sashiko-bot
2026-11-13 19:53 ` [PATCH mptcp-net 09/34] mptcp: leave an orphan's DATA_FIN to the worker Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 10/34] mptcp: don't leak an orphan when the PM closes its last subflow Matthieu Baerts (NGI0)
2026-11-13 21:10   ` sashiko-bot
2026-11-13 19:53 ` [PATCH mptcp-net 11/34] mptcp: do not use a raised snd_wnd for the send window Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 12/34] mptcp: drop non-MP_JOIN cookie ACKs on PM listeners Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 13/34] net: add __sk_net_refcnt_upgrade() with a GFP mask Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 14/34] mptcp: pm: don't let listeners pin their netns Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 15/34] mptcp: close a subflow reset for a bad mapping Matthieu Baerts (NGI0)
2026-11-13 21:40   ` sashiko-bot
2026-11-13 19:53 ` [PATCH mptcp-net 16/34] mptcp: initialize drop_req in subflow_init_req() Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 17/34] mptcp: pm: kernel: count endpoint listeners as sockets in use Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 18/34] mptcp: count a listener once when listen() is called again Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 19/34] mptcp: do not fallback while old data is in flight Matthieu Baerts (NGI0)
2026-11-13 22:29   ` sashiko-bot
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:53 ` [PATCH mptcp-net 20/34] mptcp: stop resending data to a peer that fell back Matthieu Baerts (NGI0)
2026-11-13 22:53   ` sashiko-bot
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:53 ` [PATCH mptcp-net 21/34] mptcp: pm: kernel: don't count signal+subflow ID 0 endp Matthieu Baerts (NGI0)
2026-11-13 19:54 ` [PATCH mptcp-net 22/34] selftests: mptcp: join: check re-adding " Matthieu Baerts (NGI0)
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:54 ` [PATCH mptcp-net 23/34] mptcp: use sk instead of casting msk in check_fully_established() Matthieu Baerts (NGI0)
2026-11-13 19:54 ` [PATCH mptcp-net 24/34] mptcp: push queued data on passive TFO subflows becoming established Matthieu Baerts (NGI0)
2026-11-13 19:54 ` [PATCH mptcp-net 25/34] mptcp: push queued data on passive TFO subflows falling back to TCP Matthieu Baerts (NGI0)
2026-11-13 23:54   ` sashiko-bot
2026-11-13 19:54 ` [PATCH mptcp-net 26/34] mptcp: don't send a FIN before the pending data on fallback Matthieu Baerts (NGI0)
2026-11-14  0:27   ` sashiko-bot
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:54 ` [PATCH mptcp-net 27/34] tcp: do not pass a BPF reqsk to an MPTCP listener Matthieu Baerts (NGI0)
2026-11-14  0:43   ` sashiko-bot
2026-11-13 19:54 ` [PATCH mptcp-net 28/34] mptcp: reclaim forward memory after coalescing skbs Matthieu Baerts (NGI0)
2026-11-13 19:54 ` [PATCH mptcp-net 29/34] mptcp: don't charge a shared page twice at accept() Matthieu Baerts (NGI0)
2026-11-13 19:54 ` [PATCH mptcp-net 30/34] mptcp: don't charge the backlog " Matthieu Baerts (NGI0)
2026-11-13 19:54 ` [PATCH mptcp-net 31/34] mptcp: don't charge a subflow twice when it joins during accept() Matthieu Baerts (NGI0)
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:54 ` [PATCH mptcp-net 32/34] mptcp: fix dummy mapping of overlapping segments Matthieu Baerts (NGI0)
2026-11-16 11:05   ` Geliang Tang
2026-11-16 15:28     ` Matthieu Baerts
2026-11-17 15:25       ` Matthieu Baerts
2026-11-13 19:54 ` [PATCH mptcp-net 33/34] mptcp: continue the last mapping after a fallback Matthieu Baerts (NGI0)
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:54 ` [PATCH RFC mptcp-next mptcp-net 34/34] mptcp: reset when the DSS disappears after a DATA_ACK Matthieu Baerts (NGI0)
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 21:58 ` [PATCH mptcp-net 00/34] mptcp: misc fixes MPTCP CI

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179473998528.488855.7816958320444264036@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=kuba@kernel.org \
    --cc=mason@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.