From: Paolo Abeni <pabeni@redhat.com>
To: Kuniyuki Iwashima <kuniyu@google.com>,
Neal Cardwell <ncardwell@google.com>
Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev,
Davide Caratti <dcaratti@redhat.com>,
Chris Mason <mason@kernel.org>,
stable@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Simon Horman <horms@kernel.org>,
Willem de Bruijn <willemb@google.com>,
Christoph Paasch <cpaasch@openai.com>,
"Matthieu Baerts (NGI0)" <matttbe@kernel.org>,
Mat Martineau <martineau@kernel.org>,
Eric Dumazet <edumazet@kernel.org>,
Geliang Tang <geliang@kernel.org>,
Florian Westphal <fw@strlen.de>
Subject: Re: [PATCH net 01/10] tcp: drain the queues of a listen() that fails
Date: Mon, 30 Nov 2026 19:15:49 +0100 [thread overview]
Message-ID: <e0925dd9-6c13-41e4-a2dd-9c7aa7dc25cc@redhat.com> (raw)
In-Reply-To: <20261123-net-mptcp-misc-fixes-7-4-rc5-v1-1-278042217e8d@kernel.org>
On 11/23/26 14:24, Matthieu Baerts (NGI0) wrote:
> From: Chris Mason <mason@kernel.org>
>
> If listen() fails on a TCP socket that has listened before, the sockets
> of connections from the earlier listen() can leak, together with their
> network namespace.
>
> inet_csk_listen_start() sets TCP_LISTEN before it calls get_port() and
> hash(), and its error path sets TCP_CLOSE again, then purges the Fast
> Open RST queue since commit 342e62fd34c2 ("tcp: purge Fast Open RST
> queue when listen() fails"), but not the accept queue. Pending request
> socks outlive an earlier listen() and still point to the socket, so in
> TCP_LISTEN, inet_csk_reqsk_queue_add() adds them to the accept queue,
> with their new child. These entries, and the sockets that they hold,
> are never freed, since close() drains this queue only in TCP_LISTEN and
> the next listen() stores NULL in rskq_accept_head.
>
> The fix used here is to call inet_csk_listen_stop() after the error path
> sets TCP_CLOSE, which also purges the RST queue, except for an MPTCP
> subflow, which needs mptcp_subflow_queue_clean() first: only its RST
> queue is purged here, and mptcp_listen() has to drain its accept queue,
> which is done in the next patch, "mptcp: drain the queues of a listen()
> that fails".
>
> This issue has been found with the help of an LLM, and reproduced in a
> VM, with the reproducer shared with the original version of this patch,
> run as an unprivileged user: listen() failing with EADDRINUSE in a loop,
> while the connections of an earlier listen() complete. Without this
> patch, sockets were leaked, and network namespaces too when each round
> was in its own one, without any message from the kernel:
>
> result: request socks: 10000 made, 2535 left. Sockets: 33373 made, 5070 left
> [...]
> result: namespaces: 1000 made, 694 taken down, 306 left
>
> Fixes: 079096f103fa ("tcp/dccp: install syn_recv requests into ehash table")
> Cc: stable@vger.kernel.org
> Signed-off-by: Chris Mason <mason@kernel.org>
> [ Shorter comments. Commit message: how the issue was found, and its
> symptoms. On top of commit 342e62fd34c2, with a Fixes tag for the
> accept queue. ]
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
@Kuniyuki, @Neal: an explicit ack would be appreciated here.
/P
next prev parent reply other threads:[~2026-11-30 18:15 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 13:24 [PATCH net 00/10] mptcp: misc fixes for v7.4-rc5 Matthieu Baerts (NGI0)
2026-11-23 13:24 ` [PATCH net 01/10] tcp: drain the queues of a listen() that fails Matthieu Baerts (NGI0)
2026-11-30 18:15 ` Paolo Abeni [this message]
2026-11-23 13:24 ` [PATCH net 02/10] mptcp: " Matthieu Baerts (NGI0)
2026-11-23 13:24 ` [PATCH net 03/10] mptcp: clear inet_opt in the child of an IPv6 listener Matthieu Baerts (NGI0)
2026-11-23 13:24 ` [PATCH net 04/10] mptcp: fix use-after-free of the subflow context on the delegated list Matthieu Baerts (NGI0)
2026-11-24 14:26 ` netdev-bot+sashiko
2026-11-23 13:24 ` [PATCH net 05/10] mptcp: leave an orphan's DATA_FIN to the worker Matthieu Baerts (NGI0)
2026-11-23 13:24 ` [PATCH net 06/10] mptcp: don't leak an orphan when the PM closes its last subflow Matthieu Baerts (NGI0)
2026-11-23 13:24 ` [PATCH net 07/10] net: add __sk_net_refcnt_upgrade() with a GFP mask Matthieu Baerts (NGI0)
2026-11-23 13:24 ` [PATCH net 08/10] mptcp: pm: don't let listeners pin their netns Matthieu Baerts (NGI0)
2026-11-23 19:00 ` Matthieu Baerts
2026-11-24 14:26 ` netdev-bot+sashiko
2026-11-24 16:58 ` Matthieu Baerts
2026-11-23 13:24 ` [PATCH net 09/10] mptcp: initialize drop_req in subflow_init_req() Matthieu Baerts (NGI0)
2026-11-23 13:24 ` [PATCH net 10/10] tcp: do not pass a BPF reqsk to an MPTCP listener Matthieu Baerts (NGI0)
2026-11-27 11:10 ` Jiayuan Chen
2026-11-24 16:58 ` [PATCH net 00/10] mptcp: misc fixes for v7.4-rc5 Matthieu Baerts
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=e0925dd9-6c13-41e4-a2dd-9c7aa7dc25cc@redhat.com \
--to=pabeni@redhat.com \
--cc=cpaasch@openai.com \
--cc=davem@davemloft.net \
--cc=dcaratti@redhat.com \
--cc=edumazet@kernel.org \
--cc=fw@strlen.de \
--cc=geliang@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=martineau@kernel.org \
--cc=mason@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=willemb@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox