MPTCP Linux Development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH net 08/10] mptcp: pm: don't let listeners pin their netns
Date: Tue, 24 Nov 2026 13:26:12 +0000	[thread overview]
Message-ID: <sashiko-outbox-231206@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 to consider:
- [High] mptcp: netns leak in subflow_syn_recv_sock() on non-MP_JOIN
  syncookie ACK
--

commit 6179aee66fd5371bdb738c5d1e0414c3ccde4437
Author: Josef Bacik <josef@toxicpanda.com>

mptcp: pm: don't let listeners pin their netns

This commit skips upgrading the network namespace reference count on
subflows created for kernel MPTCP sockets, and instead takes a network
namespace reference in subflow_syn_recv_sock() when cloning a child
socket from a kernel listener.

> 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
> @@ -844,6 +844,22 @@ void __mptcp_subflow_fully_established(struct mptcp_sock *msk,
>  	WRITE_ONCE(msk->fully_established, true);
>  }
>  
> +/* Children of a kernel listener need a netns ref for their timers */
> +static bool subflow_child_get_net(struct sock *child)
> +{
> +	struct net *net = sock_net(child);
> +
> +	if (likely(child->sk_net_refcnt))
> +		return true;
> +
> +	if (!maybe_get_net(net))
> +		return false;
> +
> +	__sk_net_refcnt_upgrade(child, GFP_ATOMIC);
> +	put_net(net);
> +	return true;
> +}
> +
>  static struct sock *subflow_syn_recv_sock(const struct sock *sk,
>  					  struct sk_buff *skb,
>  					  struct request_sock *req,
> @@ -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;
> +		}
> +
>  		/* 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.

[Severity: High]
Can this still leak the network namespace when SYN cookies are active on
an in-kernel PM listener?

subflow_check_req() rejects non-MP_JOIN SYNs when listener->pm_listener is
true, and for an MP_JOIN SYN under SYN cookies tcp_conn_request() sends a
SYN+ACK with a valid TCP syncookie and frees the request_sock.  If the
peer replies with a third ACK carrying that syncookie but omitting
OPTION_MPTCP_MPJ_ACK (for example, a plain TCP ACK or one carrying
OPTION_MPTCP_MPC_ACK), cookie_tcp_reqsk_init() calls
mptcp_subflow_init_cookie_req(), which does not check
listener->pm_listener and returns 0 with subflow_req->mp_join == 0.

When tcp_get_cookie_sock() then calls subflow_syn_recv_sock(),
fallback_is_fatal is false because subflow_req->mp_join is 0.
subflow_child_get_net(child) upgrades child->sk_net_refcnt to 1 before
the fallback and ctx->mp_join checks, and subflow_syn_recv_sock() returns
child with tcp_rsk(req)->drop_req == false (via goto fallback for a plain
TCP ACK, or via ctx->mp_capable after cloning listener->conn).
tcp_get_cookie_sock() then queues child into the PM listener's
icsk_accept_queue, where nothing ever accepts it, pinning the network
namespace indefinitely.

Checking listener->pm_listener in mptcp_subflow_init_cookie_req() (or
rejecting non-MP_JOIN children of a PM listener before upgrading
child->sk_net_refcnt) would prevent queueing unaccepted children with a
netns reference.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-net-mptcp-misc-fixes-7-4-rc5-v1-0-278042217e8d@kernel.org?part=8

  parent reply	other threads:[~2026-11-24 13:26 UTC|newest]

Thread overview: 23+ 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
2026-12-01  0:08     ` Kuniyuki Iwashima
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-12-01  0:09   ` Kuniyuki Iwashima
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 13:26   ` sashiko-bot [this message]
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-12-01  0:19     ` Kuniyuki Iwashima
2026-11-24 16:58 ` [PATCH net 00/10] mptcp: misc fixes for v7.4-rc5 Matthieu Baerts
2026-12-01  9:20 ` patchwork-bot+netdevbpf

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=sashiko-outbox-231206@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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