All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Geliang Tang" <geliang@kernel.org>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v4 3/7] mptcp: remove CB offset field
Date: Fri, 21 Aug 2026 07:29:52 +0000	[thread overview]
Message-ID: <20260821072953.194491F000E9@smtp.kernel.org> (raw)
In-Reply-To: <45ccd44f150d170dc2d0e11ff5350659fdd926a0.1787295147.git.tanggeliang@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] MSG_PEEK uses a stale peek_seq after msk->copied_seq is resynced, causing it to skip newly received data and stall indefinitely.
- [High] In MPTCP active fallback scenarios, msk->copied_seq is never synchronized to the IASN, causing recvmsg to silently skip all received data.
--

--- Patch [3]: [PATCH mptcp-next v4 3/7] mptcp: remove CB offset field ---
commit 05518f1ca85e68c8cc86ae9b67a0c4d849dfd066
Author: Paolo Abeni <pabeni@redhat.com>

mptcp: remove CB offset field

This commit removes the CB offset field and introduces a new msk-level
copied_seq field to track bytes already consumed inside each skb.

> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 7944ee0f93b13..d52b1773fbb6b 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
[ ... ]
> @@ -2199,33 +2192,24 @@ static void mptcp_eat_recv_skb(struct sock *sk, struct sk_buff *skb)
>  }
>  
>  static int __mptcp_recvmsg_mskq(struct sock *sk, struct msghdr *msg,
> -				size_t len, int flags, int copied_total,
> +				size_t len, int flags, u64 *seq,
>  				struct scm_timestamping_internal *tss,
>  				int *cmsg_flags, struct sk_buff **last)
>  {
>  	struct mptcp_sock *msk = mptcp_sk(sk);
>  	struct sk_buff *skb, *tmp;
> -	int total_data_len = 0;
>  	int copied = 0;
>  
>  	skb_queue_walk_safe(&sk->sk_receive_queue, skb, tmp) {
> -		u32 delta, offset = MPTCP_SKB_CB(skb)->offset;
> +		u64 offset = *seq - MPTCP_SKB_CB(skb)->map_seq;
>  		u32 data_len = skb->len - offset;
>  		u32 count;
>  		int err;
>  
> -		if (flags & MSG_PEEK) {
> -			/* skip already peeked skbs */
> -			if (total_data_len + data_len <= copied_total) {
> -				total_data_len += data_len;
> -				*last = skb;
> -				continue;
> -			}
> -
> -			/* skip the already peeked data in the current skb */
> -			delta = copied_total - total_data_len;
> -			offset += delta;
> -			data_len -= delta;
> +		/* Skip the already peeked data. */
> +		if (offset >= skb->len) {
> +			*last = skb;
> +			continue;
> +		}

[Severity: High]
During an active connection fallback, could this offset calculation underflow?

If the server replies with a SYN-ACK lacking MPTCP options, msk->copied_seq
remains 0 because MPTCP_SYNC_SEQ is bypassed during fallback. When
__mptcp_recvmsg_mskq() processes the fallback SKBs, *seq is 0 but map_seq is
set to the initial ack sequence number.

Does this subtraction underflow to a large positive value, causing
offset >= skb->len to evaluate to true and silently skip all valid
payload data?

[ ... ]
> @@ -2449,6 +2430,11 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
>  
>  	len = min_t(size_t, len, INT_MAX);
>  	target = sock_rcvlowat(sk, flags & MSG_WAITALL, len);
> +	seq = &msk->copied_seq;
> +	if (flags & MSG_PEEK) {
> +		peek_seq = msk->copied_seq;
> +		seq = &peek_seq;
> +	}
>  
>  	if (unlikely(msk->recvmsg_inq))
>  		cmsg_flags = MPTCP_CMSG_INQ;
> @@ -2458,7 +2444,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
>  		int err, bytes_read;
>  
>  		bytes_read = __mptcp_recvmsg_mskq(sk, msg, len - copied, flags,
> -						  copied, &tss, &cmsg_flags,
> +						  seq, &tss, &cmsg_flags,
>  						  &last);
>  		if (unlikely(bytes_read < 0)) {
>  			if (!copied)
> @@ -2468,6 +2454,10 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
>  
>  		copied += bytes_read;
>  
> +		/* Recompute peek offset after eventual seq resync. */
> +		if (flags & MSG_PEEK)
> +			peek_seq = msk->copied_seq + copied;
> +
>  		if (!list_empty(&msk->backlog_list) && mptcp_move_skbs(sk))
>  			continue;

[Severity: High]
When MSG_PEEK is used, could peek_seq become stale if the backlog
synchronizes the sequence?

If mptcp_move_skbs() processes the backlog and adds the initial ack sequence
number to msk->copied_seq via MPTCP_SYNC_SEQ, the loop executes a continue.

Since peek_seq was updated before mptcp_move_skbs() was called, it lacks the
new offset. On the next iteration, will calling __mptcp_recvmsg_mskq() with
this stale *seq value cause the offset calculation to underflow, skipping
the newly received data and stalling the receiver indefinitely?

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

  reply	other threads:[~2026-08-21  7:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21  7:04 [PATCH mptcp-next v4 0/7] Reduce the differences between TCP and MPTCP for TLS usage Geliang Tang
2026-08-21  7:04 ` [PATCH mptcp-next v4 1/7] mptcp: drop the mptcp_ooo_try_coalesce() helper Geliang Tang
2026-08-21  7:04 ` [PATCH mptcp-next v4 2/7] mptcp: drop the cant_coalesce CB field Geliang Tang
2026-08-21  7:04 ` [PATCH mptcp-next v4 3/7] mptcp: remove CB offset field Geliang Tang
2026-08-21  7:29   ` sashiko-bot [this message]
2026-08-21  7:04 ` [PATCH mptcp-next v4 4/7] mptcp: sync mptcp skb cb layout with tcp one Geliang Tang
2026-08-21  7:04 ` [PATCH mptcp-next v4 5/7] mptcp: defer read_sock cleanup to mptcp_worker Geliang Tang
2026-08-21  7:04 ` [PATCH mptcp-next v4 6/7] mptcp: track app-limited state in mptcp_sendmsg Geliang Tang
2026-08-21  7:04 ` [PATCH mptcp-next v4 7/7] selftests: mptcp: sockopt: check app_limited Geliang Tang
2026-08-21  8:33 ` [PATCH mptcp-next v4 0/7] 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=20260821072953.194491F000E9@smtp.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.