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 v29 7/8] mptcp: sync mptcp skb cb layout with tcp one
Date: Thu, 19 Nov 2026 05:43:44 +0000	[thread overview]
Message-ID: <sashiko-outbox-222496@kernel.org> (raw)
In-Reply-To: <f53cc2e63e8ae9a8e1d1918b247cd65368ee4b8e.1795063943.git.tanggeliang@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mptcp: broken post-DATA_FIN skb handling in
  __mptcp_recvmsg_mskq() and mptcp_recv_skb()
--

commit 620e51c1f06b815c8d3a402589fa67b46d950125
Author: Paolo Abeni <pabeni@redhat.com>

mptcp: sync mptcp skb cb layout with tcp one

This commit aligns struct mptcp_skb_cb with struct tcp_skb_cb by shrinking
map_seq and end_seq to u32, adding a 64-bit map_seq64 field, and switching
most receive-path sequence comparisons to 32-bit helpers.

> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 1ed232a4e8b4d..707a40850ada5 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
[ ... ]
> @@ -423,10 +424,11 @@ static void mptcp_init_skb(struct sock *ssk, struct sk_buff *skb, int offset,
>  
>  	/* the skb map_seq accounts for the skb offset:
>  	 * mptcp_subflow_get_mapped_dsn() is based on the current tp->copied_seq
> -	 * value
> +	 * value; note that end seq number is only available in 32bits format.
>  	 */
> -	MPTCP_SKB_CB(skb)->map_seq = mptcp_subflow_get_mapped_dsn(subflow) -
> -				     offset;
> +	MPTCP_SKB_CB(skb)->map_seq64 = mptcp_subflow_get_mapped_dsn(subflow) -
> +				       offset;
> +	MPTCP_SKB_CB(skb)->map_seq = (u32)MPTCP_SKB_CB(skb)->map_seq64;
>  	MPTCP_SKB_CB(skb)->end_seq = MPTCP_SKB_CB(skb)->map_seq + copy_len;
>  	MPTCP_SKB_CB(skb)->flags = offset ? MPTCP_SKB_CB_F_OFFSET : 0;
>  	MPTCP_SKB_CB(skb)->has_rxtstamp = has_rxtstamp;
[ ... ]
> @@ -2212,11 +2214,11 @@ static int __mptcp_recvmsg_mskq(struct sock *sk, struct msghdr *msg,
>  
>  	skb_queue_walk_safe(&sk->sk_receive_queue, skb, tmp) {
>  		u32 data_len;
> -		u64 offset;
> +		u32 offset;
>  		u32 count;
>  		int err;
>  
> -		if (unlikely(before64(*seq, MPTCP_SKB_CB(skb)->map_seq))) {
> +		if (unlikely(before64(*seq, MPTCP_SKB_CB(skb)->map_seq64))) {
>  			*seq = mptcp_end_dsn(skb);
>  			msk->bytes_consumed += skb->len;
>  			if (!(flags & MSG_PEEK))
> @@ -2226,7 +2228,7 @@ static int __mptcp_recvmsg_mskq(struct sock *sk, struct msghdr *msg,
>  			continue;
>  		}
>  
> -		offset = *seq - MPTCP_SKB_CB(skb)->map_seq;
> +		offset = (u32)(*seq) - MPTCP_SKB_CB(skb)->map_seq;
>  		data_len = skb->len - offset;
>  
>  		if (offset >= skb->len) {

[Severity: Medium]
Can testing before64(*seq, MPTCP_SKB_CB(skb)->map_seq64) in
__mptcp_recvmsg_mskq() and mptcp_recv_skb() fail to drop post-DATA_FIN
skbs and deliver garbage or post-FIN bytes to userspace?

When mptcp_check_data_fin() processes a DATA_FIN at rcv_data_fin_seq, it
advances msk->ack_seq to rcv_data_fin_seq + 1 while msk->copied_seq stops
at rcv_data_fin_seq.  __mptcp_move_skb() and __mptcp_ofo_queue() still
accept segments at dsn == rcv_data_fin_seq + 1 into sk_receive_queue, and
the before64(*seq, map_seq64) branch is meant to discard them.

Because mptcp_init_skb() sets map_seq64 to dsn - offset, a post-DATA_FIN
segment with a non-zero subflow offset (offset >= 1) has
map_seq64 == rcv_data_fin_seq + 1 - offset <= *seq.  before64(*seq,
map_seq64) is then false, and (u32)(*seq) - map_seq evaluates to
offset - 1 < skb->len.  __mptcp_recvmsg_mskq() and mptcp_recv_skb() copy
the discarded prefix byte plus copy_len post-DATA_FIN bytes to userspace
and add copy_len + 1 to msk->bytes_consumed (while msk->bytes_received was
only incremented by copy_len), underflowing mptcp_data_avail(msk).

Even when offset is 0, the discard branch sets *seq = mptcp_end_dsn(skb),
so a second post-DATA_FIN skb queued right after the first has
map_seq64 == *seq and is delivered to userspace instead of being dropped.
In __mptcp_recvmsg_mskq(), that branch also adds skb->len to
msk->bytes_consumed even when MSG_PEEK is set or when copy_len < skb->len.
Finally, if an out-of-order segment at rcv_data_fin_seq arrives before
DATA_FIN, __mptcp_ofo_queue() advances msk->ack_seq past rcv_data_fin_seq
before mptcp_pending_data_fin() runs, preventing DATA_FIN processing; and
if a post-DATA_FIN skb arrives after EOF has been read,
mptcp_data_avail(msk) becomes non-zero at close() and triggers
MP_FASTCLOSE.

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

  reply	other threads:[~2026-11-19  5:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  5:10 [PATCH mptcp-next v29 0/8] Reduce the differences between TCP and MPTCP for TLS usage Geliang Tang
2026-11-19  5:10 ` [PATCH mptcp-net v29 1/8] mptcp: clear rcv_data_fin_seq in mptcp_disconnect Geliang Tang
2026-11-20 18:41   ` netdev-bot+sashiko
2026-11-19  5:10 ` [PATCH mptcp-net v29 2/8] mptcp: fix TFO SIOCINQ overflow in mptcp_inq_hint Geliang Tang
2026-11-19  5:26   ` sashiko-bot
2026-11-20 18:41   ` netdev-bot+sashiko
2026-11-19  5:10 ` [PATCH mptcp-next v29 3/8] mptcp: drop the mptcp_ooo_try_coalesce() helper Geliang Tang
2026-11-19  5:10 ` [PATCH mptcp-next v29 4/8] mptcp: drop the cant_coalesce CB field Geliang Tang
2026-11-20 18:41   ` netdev-bot+sashiko
2026-11-19  5:10 ` [PATCH mptcp-next v29 5/8] mptcp: encapsulate CB DSN field access with helpers Geliang Tang
2026-11-20 18:41   ` netdev-bot+sashiko
2026-11-19  5:10 ` [PATCH mptcp-next v29 6/8] mptcp: remove CB offset field Geliang Tang
2026-11-20 18:41   ` netdev-bot+sashiko
2026-11-19  5:10 ` [PATCH mptcp-next v29 7/8] mptcp: sync mptcp skb cb layout with tcp one Geliang Tang
2026-11-19  5:43   ` sashiko-bot [this message]
2026-11-20 18:41   ` netdev-bot+sashiko
2026-11-19  5:10 ` [PATCH mptcp-next v29 8/8] mptcp: defer read_sock cleanup to mptcp_worker Geliang Tang

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-222496@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.