All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Geliang Tang" <geliang@kernel.org>, mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v20 2/6] mptcp: drop the cant_coalesce CB field
Date: Tue, 03 Nov 2026 09:24:21 +0000	[thread overview]
Message-ID: <sashiko-outbox-194951@kernel.org> (raw)
In-Reply-To: <9bd00acf2721c30b79fd852167b5b1343a2d67a0.1793695518.git.tanggeliang@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mptcp: mptcp_inq_hint() seq mismatch when MPTCP_SYNC_SEQ is deferred
--

commit 198606f4de002c65c8846681be2fa1a33a1379e5
Author: Paolo Abeni <pabeni@redhat.com>

mptcp: drop the cant_coalesce CB field

This commit removes the cant_coalesce field from struct mptcp_skb_cb and
synchronizes the passive Fast Open skb sequence numbers with the peer's
initial ACK sequence number once the 3rd ACK arrives. When the socket is
owned by user space at 3rd ACK arrival, synchronization is deferred via
the MPTCP_SYNC_SEQ flag in cb_flags.

> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index 78e886b202585..8a3ba490b5772 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
> @@ -515,6 +515,8 @@ static void subflow_set_remote_key(struct mptcp_sock *msk,
>  				   struct mptcp_subflow_context *subflow,
>  				   const struct mptcp_options_received *mp_opt)
>  {
> +	struct sock *sk = (struct sock *)msk;
> +
>  	/* active MPC subflow will reach here multiple times:
>  	 * at subflow_finish_connect() time and at 4th ack time
>  	 */
> @@ -533,6 +535,12 @@ static void subflow_set_remote_key(struct mptcp_sock *msk,
>  	WRITE_ONCE(msk->ack_seq, subflow->iasn);
>  	WRITE_ONCE(msk->can_ack, true);
>  	atomic64_set(&msk->rcv_wnd_sent, subflow->iasn);
> +	msk->tfo_iasn = subflow->iasn;
> +
> +	if (!sock_owned_by_user(sk))
> +		__mptcp_sync_rcv_sequence(sk);
> +	else
> +		set_bit(MPTCP_SYNC_SEQ, &msk->cb_flags);

[Severity: Medium]
As reported by Sashiko on v15 [1], when the 3rd ACK arrives on a passive Fast
Open socket while user space holds the socket lock, subflow_set_remote_key()
immediately updates msk->ack_seq to subflow->iasn while deferring
__mptcp_sync_rcv_sequence() via MPTCP_SYNC_SEQ.

Until MPTCP_SYNC_SEQ is processed, the TFO skb in sk->sk_receive_queue still
carries its dummy sequence mapping (MPTCP_SKB_CB(skb)->map_seq = -skb->len
plus any consumed offset). If mptcp_inq_hint() is called under lock_sock(sk)
during that window, it subtracts the dummy map_seq from the newly updated
msk->ack_seq:

net/mptcp/protocol.c:mptcp_inq_hint() {
	skb = skb_peek(&sk->sk_receive_queue);
	if (skb) {
		u64 hint_val = READ_ONCE(msk->ack_seq) - MPTCP_SKB_CB(skb)->map_seq;

		if (hint_val >= INT_MAX)
			return INT_MAX;

		return (unsigned int)hint_val;
	}
}

This can happen before release_sock(sk) runs mptcp_release_cb() in three
paths:

1. mptcp_recvmsg() -> __mptcp_recvmsg_mskq() -> mptcp_rcv_space_adjust()
   calls mptcp_inq_hint(sk) before mptcp_move_skbs(sk) is invoked, which can
   underflow copied -= mptcp_inq_hint(sk).

2. mptcp_recvmsg() skips mptcp_move_skbs(sk) when msk->backlog_list is empty
   (for example when the 3rd ACK carries no payload) and then calls
   mptcp_inq_hint(sk) for TCP_CM_INQ:

net/mptcp/protocol.c:mptcp_recvmsg() {
		if (!list_empty(&msk->backlog_list) && mptcp_move_skbs(sk))
			continue;
		...
		if (cmsg_flags & MPTCP_CMSG_INQ) {
			unsigned int inq = mptcp_inq_hint(sk);

			put_cmsg(msg, SOL_TCP, TCP_CM_INQ, sizeof(inq), &inq);
		}
}

3. In mptcp_ioctl() for SIOCINQ, if the 3rd ACK arrives in BH after
   mptcp_move_skbs(sk) drops mptcp_data_lock(sk) and before
   mptcp_inq_hint(sk) reads msk->ack_seq:

net/mptcp/protocol.c:mptcp_ioctl() {
		lock_sock(sk);
		if (mptcp_move_skbs(sk))
			mptcp_cleanup_rbuf(msk, 0);
		*karg = mptcp_inq_hint(sk);
		release_sock(sk);
}

Could this cause mptcp_inq_hint() to return INT_MAX (or a bogus value derived
from subflow->iasn) to user space for TCP_CM_INQ and SIOCINQ, and corrupt the
receive buffer space calculation in mptcp_rcv_space_adjust()?

[1] https://lore.kernel.org/r/25f42bae1af43649a5c89ca10cfe0d962941c6f7.1792718041.git.tanggeliang@kylinos.cn

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1793695518.git.tanggeliang@kylinos.cn?part=2

  reply	other threads:[~2026-11-03  9:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03  8:57 [PATCH mptcp-next v20 0/6] Reduce the differences between TCP and MPTCP for TLS usage Geliang Tang
2026-11-03  8:57 ` [PATCH mptcp-next v20 1/6] mptcp: drop the mptcp_ooo_try_coalesce() helper Geliang Tang
2026-11-03  8:57 ` [PATCH mptcp-next v20 2/6] mptcp: drop the cant_coalesce CB field Geliang Tang
2026-11-03  9:24   ` sashiko-bot [this message]
2026-11-03  8:57 ` [PATCH mptcp-next v20 3/6] mptcp: fix TFO map_seq sign extension in fastopen Geliang Tang
2026-11-03  9:38   ` sashiko-bot
2026-11-03  8:57 ` [PATCH mptcp-next v20 4/6] mptcp: remove CB offset field Geliang Tang
2026-11-03 10:21   ` sashiko-bot
2026-11-03  8:57 ` [PATCH mptcp-next v20 5/6] mptcp: sync mptcp skb cb layout with tcp one Geliang Tang
2026-11-03 10:43   ` sashiko-bot
2026-11-03  8:57 ` [PATCH mptcp-next v20 6/6] mptcp: defer read_sock cleanup to mptcp_worker Geliang Tang
2026-11-03 11:08   ` sashiko-bot
2026-11-03 10:22 ` [PATCH mptcp-next v20 0/6] Reduce the differences between TCP and MPTCP for TLS usage 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=sashiko-outbox-194951@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=geliang@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 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.