All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthieu Baerts <matttbe@kernel.org>
To: Ren Wei <weir@nebusec.ai>, netdev@vger.kernel.org, mptcp@lists.linux.dev
Cc: martineau@kernel.org, geliang@kernel.org, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org, ncardwell@google.com, kuniyu@google.com,
	daniel@iogearbox.net, kafai@fb.com, kylebot@openai.com,
	david.lee@trailofbits.com, vega@nebusec.ai,
	caoruide123@gmail.com, sashiko-bot@kernel.org
Subject: Re: [PATCH net v3 2/2] mptcp: fix MP_CAPABLE token migration when cloning reqsk
Date: Sun, 9 Aug 2026 20:03:31 +0200	[thread overview]
Message-ID: <5ac3773c-4a6f-4796-a43f-545c3c42271c@kernel.org> (raw)
In-Reply-To: <a12d76b7f2305b5a8d64c3d6c3585e39684ff792.1785995291.git.caoruide123@gmail.com>

Hi Ren, Ruide,

On 06/08/2026 13:14, Ren Wei wrote:
> From: Ruide Cao <caoruide123@gmail.com>
> 
> TCP request migration clones pending request sockets with
> inet_reqsk_clone().  For MPTCP MP_CAPABLE requests this byte-copies the
> token_node hlist state into the clone even though the token table still
> names the original request.
> 
> Moving the token only after inet_ehash_insert() succeeds leaves a window
> where the cloned request is already globally visible from the ehash but
> the token table still points at the original request.  Reordering the
> move after clone but before ehash exposure closes that window, but
> concurrent RX can still race on the old request and observe that the
> token was already moved.
> 
> Move MP_CAPABLE token request ownership during MPTCP request cloning
> under the token bucket lock.  Make mptcp_token_accept() and
> mptcp_token_destroy_request() re-check token_node under the same lock and
> treat an already moved or removed request as a normal race instead of
> warning.
> 
> If the passive MP_CAPABLE socket cannot claim the token, fail
> mptcp_sk_clone_init() and let the subflow fall back instead of
> installing a socket with mismatched token ownership.

Thank you for the new version!

I have one major comment, please see below:
> Fixes: c905dee62232 ("tcp: Migrate TCP_NEW_SYN_RECV requests at retransmitting SYN+ACKs.")
> Cc: stable@vger.kernel.org
> Reported-by: Vega <vega@nebusec.ai>
> Assisted-by: Codex:gpt-5.4
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/patchset/86e2514b533bf4d55d4aa2fdbf1404022e8c9430.1776149210.git.caoruide123%40gmail.com
> Signed-off-by: Ruide Cao <caoruide123@gmail.com>
> Signed-off-by: Ren Wei <weir@nebusec.ai>
> ---
>  net/mptcp/protocol.c   | 12 +++++----
>  net/mptcp/protocol.h   |  4 ++-
>  net/mptcp/subflow.c    |  2 ++
>  net/mptcp/token.c      | 61 +++++++++++++++++++++++++++++++++++++-----
>  net/mptcp/token_test.c |  4 +--
>  5 files changed, 68 insertions(+), 15 deletions(-)
> 
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index ca644ec53eed..07eaa6858d05 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -3608,17 +3608,19 @@ struct sock *mptcp_sk_clone_init(const struct sock *sk,
>  	 */
>  	mptcp_set_state(nsk, TCP_ESTABLISHED);
>  
> +	if (!mptcp_token_accept(subflow_req, msk)) {
> +		mptcp_release_sched(msk);
> +		inet_csk_prepare_forced_close(nsk);
> +		tcp_done(nsk);

Here, you cannot call tcp_done(nsk): nsk is an MPTCP socket, not a TCP
one. You probably want to destroy the msk instead.

(In theory, your reproducer launched on a kernel with your patches
applied on top of MPTCP's export branch [1] should produce a warning)

Apart from that, Clashiko has a few comments. Do you mind checking them
and reply to each comment here, before sending a new version, whether
you agree/disagree or if it is unclear, please?

[1] https://github.com/multipath-tcp/mptcp_net-next/

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.
pw-bot: cr


  reply	other threads:[~2026-08-09 18:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06 11:14 [PATCH net v3 0/2] mptcp: fix request migration ownership Ren Wei
2026-08-06 11:14 ` [PATCH net v3 1/2] mptcp: hold MP_JOIN msk ref when cloning reqsk Ren Wei
2026-08-06 11:14 ` [PATCH net v3 2/2] mptcp: fix MP_CAPABLE token migration " Ren Wei
2026-08-09 18:03   ` Matthieu Baerts [this message]
2026-08-11 19:05     ` Ryder Grass
2026-08-06 12:31 ` [PATCH net v3 0/2] mptcp: fix request migration ownership MPTCP CI
2026-08-06 12:43 ` Matthieu Baerts
2026-08-07  8:05   ` Nebula Security

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=5ac3773c-4a6f-4796-a43f-545c3c42271c@kernel.org \
    --to=matttbe@kernel.org \
    --cc=caoruide123@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=david.lee@trailofbits.com \
    --cc=edumazet@google.com \
    --cc=geliang@kernel.org \
    --cc=horms@kernel.org \
    --cc=kafai@fb.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=kylebot@openai.com \
    --cc=martineau@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sashiko-bot@kernel.org \
    --cc=vega@nebusec.ai \
    --cc=weir@nebusec.ai \
    /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.