All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geliang Tang <geliang@kernel.org>
To: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>,
	MPTCP Linux <mptcp@lists.linux.dev>
Cc: Chris Mason <mason@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH mptcp-net 32/34] mptcp: fix dummy mapping of overlapping segments
Date: Mon, 16 Nov 2026 19:05:22 +0800	[thread overview]
Message-ID: <c504da100dc5c5028bda391a6aabf0485464145c.camel@kernel.org> (raw)
In-Reply-To: <20261113-mptcp-cmason-fixes-v1-32-9205b77e9a2f@kernel.org>

Hi Matt,

On Fri, 2026-11-13 at 20:54 +0100, Matthieu Baerts (NGI0) wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> An MPTCP socket that has fallen back to TCP can silently lose received
> data if a segment partly overlaps data received earlier, and recv() then
> blocks, returning neither later data nor end of file.
> 
> After a fallback, subflow_check_data_avail() makes up a dummy mapping
> for the skb at the head of the subflow's receive queue, in which map_seq
> and map_subflow_seq must describe the same byte. But since commit
> 2834f8edd74d ("mptcp: cleanup fallback dummy mapping generation"), it
> computes map_seq from the first byte of the skb, while map_subflow_seq
> is still computed from copied_seq, the next unread byte.
> mptcp_subflow_get_mapped_dsn() then returns the data sequence number
> (DSN) of the first byte of the skb, instead of the one of copied_seq.
> 
> These two bytes differ for a segment that starts before rcv_nxt and ends
> after it, since TCP does not trim it. mptcp_init_skb() then gives the
> new bytes of this skb a DSN that is too low, and __mptcp_move_skb()
> skips some of them as old data, leaving a hole in the stream:
> 
>     bytes 0 to 999 are received, the skb holds bytes 900 to 1499
>       byte 1000 gets the DSN of byte 900: too low by the 100 old bytes
>         that is 100 below ack_seq, the next DSN that MPTCP expects
>           __mptcp_move_skb() skips bytes 1000 to 1099 as old data
>             ack_seq is the DSN of byte 1400, copied_seq is byte 1500
>               later data starts at the DSN of byte 1500: out of order
>                 the TCP FIN becomes a dummy DATA_FIN after the last byte
>                   ack_seq does not reach it, so there is no end of file
> 
> Fix this by computing map_subflow_seq from the first byte of the skb as
> well: mptcp_subflow_get_mapped_dsn() then returns the DSN of copied_seq.
> 
> Chris Mason sent the same fix in private, and found this issue with the
> help of an LLM. It has been reproduced in a VM, with the reproducer he
> shared, and with a new Packetdrill test: after a fallback to TCP, a
> segment overlapping data already received is injected. Without this
> patch, the new bytes at the beginning of this segment were lost, and the
> connection stalled, with no end of file:
> 
>   reader   30.64: conn 1 BREAK: at my offset 1000 the bytes claim offset 1100: A GAP OF 100 BYTES
>   reader   30.64: READ-TOTAL conn 1 outcome iii-gap-or-repeat bytes 1400 of 2500 [...]
>   [...] end: hang: no data and no end of file for 30 s
> 
> And with the Packetdrill test:
> 
>   dss_fallback_overlap_client.pkt:24: runtime error in read call: Expected result 2500 but got 1400 with errno 115 (Operation now in progress)
> 
> Fixes: 2834f8edd74d ("mptcp: cleanup fallback dummy mapping generation")
> Link: https://lore.kernel.org/4c48d016490d43b6892c622cbae858b48f176cff.1794304840.git.tanggeliang@kylinos.cn [1]
> Co-developed-by: Chris Mason <mason@kernel.org>
> Signed-off-by: Chris Mason <mason@kernel.org>
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> [ Combine the commit messages of Geliang's [1] and Chris's versions.
>   Commit message: how the issue was found, and its symptoms. ]
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>

This fix LGTM! - sashiko has no complaints about it too. Could you please apply
this patch to the export branch first, so that I don't have to carry it along in
every iteration of the "Reduce the differences between TCP and MPTCP for TLS
usage" series? Also, Chris and I both sent out this same fix at different times,
which further confirms from another angle that this fix works.

Thanks,
-Geliang

> ---
>  net/mptcp/subflow.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index 543368cfc890..64e8f5c36415 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
> @@ -1526,7 +1526,7 @@ static bool subflow_check_data_avail(struct sock *ssk)
>  	skb = skb_peek(&ssk->sk_receive_queue);
>  	subflow->map_valid = 1;
>  	subflow->map_data_len = skb->len;
> -	subflow->map_subflow_seq = tcp_sk(ssk)->copied_seq - subflow->ssn_offset;
> +	subflow->map_subflow_seq = TCP_SKB_CB(skb)->seq - subflow->ssn_offset;
>  	subflow->map_seq = __mptcp_expand_seq(subflow->map_seq,
>  					      subflow->iasn +
>  					      TCP_SKB_CB(skb)->seq -

  reply	other threads:[~2026-11-16 11:05 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 19:53 [PATCH mptcp-net 00/34] mptcp: misc fixes Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 01/34] tcp: drain the queues of a listen() that fails Matthieu Baerts (NGI0)
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:53 ` [PATCH mptcp-net 02/34] mptcp: " Matthieu Baerts (NGI0)
2026-11-13 20:13   ` sashiko-bot
2026-11-13 19:53 ` [PATCH mptcp-net 03/34] mptcp: clear inet_opt in the child of an IPv6 listener Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 04/34] mptcp: pm: work on a copy of the received RM_ADDR list Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 05/34] mptcp: pm: don't drop an RM_ADDR behind a pending one Matthieu Baerts (NGI0)
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:53 ` [PATCH mptcp-net 06/34] mptcp: pm: don't drop an RM_ADDR because of an ADD_ADDR Matthieu Baerts (NGI0)
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:53 ` [PATCH mptcp-net 07/34] mptcp: arm the rtx timer if a push leaves data behind Matthieu Baerts (NGI0)
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:53 ` [PATCH mptcp-net 08/34] mptcp: force the charge for the first skb of a subflow Matthieu Baerts (NGI0)
2026-11-13 20:09   ` sashiko-bot
2026-11-13 19:53 ` [PATCH mptcp-net 09/34] mptcp: leave an orphan's DATA_FIN to the worker Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 10/34] mptcp: don't leak an orphan when the PM closes its last subflow Matthieu Baerts (NGI0)
2026-11-13 21:10   ` sashiko-bot
2026-11-13 19:53 ` [PATCH mptcp-net 11/34] mptcp: do not use a raised snd_wnd for the send window Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 12/34] mptcp: drop non-MP_JOIN cookie ACKs on PM listeners Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 13/34] net: add __sk_net_refcnt_upgrade() with a GFP mask Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 14/34] mptcp: pm: don't let listeners pin their netns Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 15/34] mptcp: close a subflow reset for a bad mapping Matthieu Baerts (NGI0)
2026-11-13 21:40   ` sashiko-bot
2026-11-13 19:53 ` [PATCH mptcp-net 16/34] mptcp: initialize drop_req in subflow_init_req() Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 17/34] mptcp: pm: kernel: count endpoint listeners as sockets in use Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 18/34] mptcp: count a listener once when listen() is called again Matthieu Baerts (NGI0)
2026-11-13 19:53 ` [PATCH mptcp-net 19/34] mptcp: do not fallback while old data is in flight Matthieu Baerts (NGI0)
2026-11-13 22:29   ` sashiko-bot
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:53 ` [PATCH mptcp-net 20/34] mptcp: stop resending data to a peer that fell back Matthieu Baerts (NGI0)
2026-11-13 22:53   ` sashiko-bot
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:53 ` [PATCH mptcp-net 21/34] mptcp: pm: kernel: don't count signal+subflow ID 0 endp Matthieu Baerts (NGI0)
2026-11-13 19:54 ` [PATCH mptcp-net 22/34] selftests: mptcp: join: check re-adding " Matthieu Baerts (NGI0)
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:54 ` [PATCH mptcp-net 23/34] mptcp: use sk instead of casting msk in check_fully_established() Matthieu Baerts (NGI0)
2026-11-13 19:54 ` [PATCH mptcp-net 24/34] mptcp: push queued data on passive TFO subflows becoming established Matthieu Baerts (NGI0)
2026-11-13 19:54 ` [PATCH mptcp-net 25/34] mptcp: push queued data on passive TFO subflows falling back to TCP Matthieu Baerts (NGI0)
2026-11-13 23:54   ` sashiko-bot
2026-11-13 19:54 ` [PATCH mptcp-net 26/34] mptcp: don't send a FIN before the pending data on fallback Matthieu Baerts (NGI0)
2026-11-14  0:27   ` sashiko-bot
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:54 ` [PATCH mptcp-net 27/34] tcp: do not pass a BPF reqsk to an MPTCP listener Matthieu Baerts (NGI0)
2026-11-14  0:43   ` sashiko-bot
2026-11-13 19:54 ` [PATCH mptcp-net 28/34] mptcp: reclaim forward memory after coalescing skbs Matthieu Baerts (NGI0)
2026-11-13 19:54 ` [PATCH mptcp-net 29/34] mptcp: don't charge a shared page twice at accept() Matthieu Baerts (NGI0)
2026-11-13 19:54 ` [PATCH mptcp-net 30/34] mptcp: don't charge the backlog " Matthieu Baerts (NGI0)
2026-11-13 19:54 ` [PATCH mptcp-net 31/34] mptcp: don't charge a subflow twice when it joins during accept() Matthieu Baerts (NGI0)
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:54 ` [PATCH mptcp-net 32/34] mptcp: fix dummy mapping of overlapping segments Matthieu Baerts (NGI0)
2026-11-16 11:05   ` Geliang Tang [this message]
2026-11-16 15:28     ` Matthieu Baerts
2026-11-17 15:25       ` Matthieu Baerts
2026-11-13 19:54 ` [PATCH mptcp-net 33/34] mptcp: continue the last mapping after a fallback Matthieu Baerts (NGI0)
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 19:54 ` [PATCH RFC mptcp-next mptcp-net 34/34] mptcp: reset when the DSS disappears after a DATA_ACK Matthieu Baerts (NGI0)
2026-11-15 10:53   ` netdev-bot+sashiko
2026-11-13 21:58 ` [PATCH mptcp-net 00/34] mptcp: misc fixes 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=c504da100dc5c5028bda391a6aabf0485464145c.camel@kernel.org \
    --to=geliang@kernel.org \
    --cc=mason@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=pabeni@redhat.com \
    /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.