From: netdev-bot+sashiko@kernel.org
To: matttbe@kernel.org
Cc: edumazet@kernel.org, davem@davemloft.net, kuba@kernel.org,
pabeni@redhat.com, willemb@google.com, horms@kernel.org,
martineau@kernel.org, geliang@kernel.org, cpaasch@openai.com,
fw@strlen.de, netdev@vger.kernel.org, mptcp@lists.linux.dev,
dcaratti@redhat.com, mason@kernel.org, stable@vger.kernel.org,
ncardwell@google.com, kuniyu@google.com, kafai@fb.com,
daniel@iogearbox.net, ast@kernel.org, martin.lau@kernel.org,
bpf@vger.kernel.org
Subject: Re: [PATCH net 08/10] mptcp: pm: don't let listeners pin their netns
Date: Tue, 24 Nov 2026 14:26:53 +0000 [thread overview]
Message-ID: <179553041337.3135.9610172277728846515@kernel.org> (raw)
In-Reply-To: <20261123-net-mptcp-misc-fixes-7-4-rc5-v1-8-278042217e8d@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 netns leak this patch claims to fix can still be triggered
through the SYN-cookie path.
--
mptcp: pm: don't let listeners pin their netns
This patch stops the subflow of an in-kernel PM listener from taking a
netns reference when its MPTCP socket is a kernel socket. As a result, a
"signal" endpoint with a port no longer pins its namespace. Children cloned
from such a listener in subflow_syn_recv_sock() now take the reference
themselves, using __sk_net_refcnt_upgrade() in atomic context.
> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index 20d5062350742..3e674c21bdb2a 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
[ ... ]
> @@ -912,6 +928,11 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
>
> tcp_rsk(req)->drop_req = false;
>
> + if (!subflow_child_get_net(child)) {
> + subflow_add_reset_reason(skb, MPTCP_RST_EUNSPEC);
> + goto dispose_child;
> + }
> +
[Severity: High]
Can the namespace still get pinned through the syncookie path here?
mptcp_subflow_create_socket() no longer upgrades the PM listener ssk, so
every child cloned from it inherits sk_net_refcnt == 0. Here
subflow_child_get_net() runs for every owned child, before the
!ctx || fallback check and the mp_capable / mp_join branching. That means
plain-TCP fallback children and MP_CAPABLE children of a PM listener also
get a real netns reference. The commit message only mentions MP_JOIN
children needing one.
On a pm_listener, MPC and plain requests are rejected only at SYN time, in
subflow_check_req():
if (opt_mp_capable) {
...
if (unlikely(listener->pm_listener))
return subflow_reset_req_endp(req, skb);
} else if (opt_mp_join) {
...
} else if (unlikely(listener->pm_listener)) {
return subflow_reset_req_endp(req, skb);
}
mptcp_subflow_init_cookie_req() has no such check. It picks mp_capable or
mp_join from the options in the third ACK only:
opt_mp_capable = !!(mp_opt.suboptions & OPTION_MPTCP_MPC_ACK);
opt_mp_join = !!(mp_opt.suboptions & OPTION_MPTCP_MPJ_ACK);
if (opt_mp_capable && listener->request_mptcp) {
Syncookies are in effect when net.ipv4.tcp_syncookies=2 (a per-netns
setting) or when the SYN queue is full. In that case, could this sequence
happen?
1. An MP_JOIN SYN with a valid token passes subflow_check_req() and gets
a cookie SYN-ACK.
2. The third ACK has no MPJ_ACK, or has MPC_ACK instead.
3. cookie_tcp_reqsk_init() leaves mp_join = 0, so fallback_is_fatal is
false. In the plain case the child falls back with ctx == NULL. In the
MPC case it clones the kernel listener msk.
4. subflow_child_get_net() sets sk_net_refcnt = 1 on the child, which is
then returned with drop_req == false.
tcp_get_cookie_sock() then puts the child on the PM listener's accept
queue:
if (rsk_drop_req(req)) {
reqsk_put(req);
return child;
}
if (inet_csk_reqsk_queue_add(sk, req, child))
return child;
Nothing ever accepts from that queue. Only inet_csk_listen_stop() drains
it, either when the endpoint is deleted or from pm_nl_exit_net(). But
pm_nl_exit_net() can't run while the queued child holds the netns
reference. Doesn't that leak the namespace the same way as before this
patch?
The setup is the same as the commit's reproducer: an unprivileged user in
their own user and net namespace. That user can set tcp_syncookies, get a
token from a loopback connection via MPTCP_INFO, and use CAP_NET_RAW to
send the MP_JOIN SYN and a bare ACK. While cookies are active, a remote
peer that knows a token could also trigger it, and so could a middlebox
that strips MPJ_ACK.
The later patches in this series, "mptcp: initialize drop_req in
subflow_init_req()" and "tcp: do not pass a BPF reqsk to an MPTCP
listener", don't seem to change this.
Could the reference be taken only for MP_JOIN children that get attached
to an msk? Another option would be to reject non-MP_JOIN cookie ACKs on a
pm_listener in mptcp_subflow_init_cookie_req().
> /* we need to fallback on ctx allocation failure and on pre-reqs
> * checking above. In the latter scenario we additionally need
> * to reset the context to non MPTCP status.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123-net-mptcp-misc-fixes-7-4-rc5-v1-0-278042217e8d%40kernel.org
next prev parent reply other threads:[~2026-11-24 14:26 UTC|newest]
Thread overview: 14+ 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-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 [this message]
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)
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=179553041337.3135.9610172277728846515@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cpaasch@openai.com \
--cc=daniel@iogearbox.net \
--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=kafai@fb.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=martin.lau@kernel.org \
--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=pabeni@redhat.com \
--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