mptcp: misc fixes for v7.4-rc4
Subsystems (4)
Matthieu Baerts (NGI0)
maintainercover mptcp: misc fixes for v7.4-rc4
Here are some unrelated fixes:
- Patch 1: do not send data beyond the window announced by the peer. A fix for v5.11.
- Patch 2: push pending data after a sendmsg copy fault. A fix for v6.1.
- Patches 3-6: with TFO, send the data written by a server before the third ACK as soon as this ACK arrives, also in case of fallback to TCP, even if the connection was shut down. Fixes for v6.2 and v5.19.
- Patch 7: after a fallback, fix the dummy mapping of overlapping segments. A fix for v6.19.
---
Geliang Tang (1):
mptcp: fix dummy mapping of overlapping segments
Matthieu Baerts (NGI0) (5):
mptcp: do not use a raised snd_wnd for the send window
mptcp: use sk instead of casting msk in check_fully_established()
mptcp: push queued data on passive TFO subflows becoming established
mptcp: push queued data on subflows falling back at the handshake
mptcp: don't send a FIN before the pending data on fallback
Quanye Yang (1):
mptcp: push pending data after a sendmsg copy fault
net/mptcp/options.c | 23 +++++++++++++++++++---- net/mptcp/protocol.c | 4 +++- net/mptcp/protocol.h | 6 +++++- net/mptcp/subflow.c | 2 +- 4 files changed, 28 insertions(+), 7 deletions(-)
---
base-commit: aa40afa831ebfe45e40a23721711059f2ac584d4
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git main
change-id: 20261116-net-mptcp-misc-fixes-7-4-rc4-9dc946f31d92
Best regards,
Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>
Matthieu Baerts (NGI0)
maintainerPATCH 1/7 mptcp: do not use a raised snd_wnd for the send window
ack_update_msk() sets the right edge of the MPTCP send window from the DATA_ACK and tcp_sk(ssk)->snd_wnd, but this is not always what the peer
announced: mptcp_check_allowed_size() raises it to window_end - data_seq, so that TCP lets through what the MPTCP-level window allows.
That is fine for new data. For data sent again, data_seq can be below snd_una, and snd_wnd ends up too large by the difference. TCP only overwrites it when an ACK moves things forward on this subflow, see tcp_may_update_window(). If a DATA_ACK moved by another subflow comes in on this subflow before that, wnd_end goes past what the peer offered. It only moves forward, so it stays there.
The sender then transmits data beyond the peer's window: the peer drops it (MPTCP_MIB_NODSSWINDOW) after TCP acked it, and only an MPTCP-level retransmission can recover it, which raises snd_wnd again. The connection can then stay stuck at a low rate for several seconds, with nothing in flight on any subflow.
This raise has been added by commit b713d0067574 ("mptcp: really share subflow snd_wnd"), but snd_wnd could already be too large before: when nothing moves at the TCP level, tcp_may_update_window() ignores a lower non-zero window, while the peer can announce one with a DATA_ACK that moved, keeping the same right edge.
Use the window announced in the packet carrying the DATA_ACK instead.
In my case with BBR, a small TCP rmem, and a second path with a much higher latency, a lower throughput and some losses, this small change can double the throughput in the worst cases.
The issue has been reproduced with a new Packetdrill test, on a single
subflow: the data is acked by TCP, then by MPTCP with a lower window, keeping the same right edge. Without this patch, the 2000 bytes written next were sent, instead of the 1280 bytes up to this right edge:
dss_dack_window_server.pkt:23: error handling packet: live packet payload: expected 1280 bytes vs actual 2000 bytes
--- net/mptcp/options.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
net/mptcp/options.c +9 -2
@@ -1120,9 +1120,11 @@ static void rwin_update(struct mptcp_sock *msk, struct sock *ssk,static void ack_update_msk (struct mptcp_sock *msk,struct sock *ssk, +const struct sk_buff *skb,struct mptcp_options_received *mp_opt) {u64 new_wnd_end, new_snd_una, old_snd_una; +u32 win =ntohs (tcp_hdr (skb)->window);struct sock *sk = (struct sock *)msk;u64 snd_nxt;
@@ -1143,7 +1145,12 @@ static void ack_update_msk(struct mptcp_sock *msk, after64(new_snd_una, snd_nxt))) new_snd_una = old_snd_una; - new_wnd_end = new_snd_una +tcp_sk (ssk)->snd_wnd; +/* What the peer announced: tcp_sk(ssk)->snd_wnd can be larger, see +* mptcp_check_allowed_size(), and is not always updated. +*/ +if (likely (!tcp_hdr (skb)->syn)) + win <<=tcp_sk (ssk)->rx_opt.snd_wscale; + new_wnd_end = new_snd_una + win;if (after64 (new_wnd_end, msk->wnd_end))WRITE_ONCE (msk->wnd_end, new_wnd_end);
@@ -1313,7 +1320,7 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)* monodirectional flows will stuck */ if (mp_opt.use_ack) -ack_update_msk (msk, sk, &mp_opt); +ack_update_msk (msk, sk, skb, &mp_opt);rwin_update (msk, sk, skb);/* Zero-data-length packets are dropped by the caller and not
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH 2/7 mptcp: push pending data after a sendmsg copy fault
In reply to Matthieu Baerts (NGI0)From: Quanye Yang <[email protected]>
mptcp_sendmsg() copies into the msk write queue first, then __mptcp_push_pending() on the success path. tcp_sendmsg_locked() does the opposite: its do_error path jumps to out, and out calls tcp_push() when copied > 0.
A later iovec fault (copy_from_iter / -EFAULT) after a successful iteration therefore returns the partial byte count but leaves the already-queued dfrag on rtx_queue. No subflow packet is sent, no retransmission timer is armed, and DATA_FIN stays blocked on first_pending.
Push in do_error when copied is already non-zero. Do not move the push to out: copied is a size_t, and sk_stream_error() stores a negative errno there.
The issue was spot by Sashiko, but easy to reproduce with Packetdrill:
writev(4, [{..., 32728}, {NULL, 4096}], 2) = 32728
--- net/mptcp/protocol.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/mptcp/protocol.c +3 -1
@@ -2130,8 +2130,10 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)return copied; do_error: -if (copied) +if (copied) { +__mptcp_push_pending (sk, msg->msg_flags); goto out; + } copied =sk_stream_error (sk, msg->msg_flags, ret); goto out;
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH net 2/7] mptcp: push pending data after a sendmsg copy fault
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] mptcp: Fixes trailer in commit message cites 69800e516e96 instead of d9ca1de8c0cd --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] mptcp: Fixes trailer in commit message cites 69800e516e96 instead of d9ca1de8c0cd
--
commit 54f71c9aefbcf7d32b7ddbd0cfb6524d738c4d31
Author: Quanye Yang <[email protected]>
Quoted 19 lines
mptcp: push pending data after a sendmsg copy fault
mptcp_sendmsg()copies into the msk write queue first, then__mptcp_push_pending()on the success path.tcp_sendmsg_locked()does the opposite: itsdo_errorpath jumps to out, and out callstcp_push()when copied > 0.A later iovec fault (
copy_from_iter/-EFAULT) after a successful iteration therefore returns the partial byte count but leaves the already-queued dfrag onrtx_queue. No subflow packet is sent, no retransmission timer is armed, andDATA_FINstays blocked onfirst_pending.Push in
do_errorwhen copied is already non-zero. Do not move the push to out: copied is asize_t, andsk_stream_error()stores a negative errno there.The issue was spot by Sashiko, but easy to reproduce with Packetdrill:
Quoted 8 lines
writev(4, [{..., 32728}, {NULL, 4096}], 2)= 32728Fixes 69800e516e96 ("mptcp: propagate fastclose error")Signed-off-by Quanye Yang <[email protected]>Reviewed-by Matthieu Baerts (NGI0) <[email protected]>Signed-off-by Matthieu Baerts (NGI0) <[email protected]>
[Severity: Low]
Should the Fixes: tag point to d9ca1de8c0cd ("mptcp: move page frag allocation in mptcp_sendmsg()") instead?
Before 69800e516e96 ("mptcp: propagate fastclose error"), a copy_page_from_iter() failure in mptcp_sendmsg() already jumped directly to out:, bypassing __mptcp_push_pending() and returning the partial byte count when copied > 0. Commit d9ca1de8c0cd ("mptcp: move page frag allocation in mptcp_sendmsg()") introduced the loop that queues data into msk->rtx_queue first and pushes only after the loop, while jumping past mptcp_push_pending() to out: on a copy fault.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261116-net-mptcp-misc-fixes-7-4-rc4-v1-0-bf7656de653e@kernel.org?part=2
[email protected]
AI reviewRe: [PATCH net 2/7] mptcp: push pending data after a sendmsg copy fault
In reply to Matthieu Baerts (NGI0)Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] mptcp: Fixes trailer in commit message cites 69800e516e96 instead of d9ca1de8c0cd
--
Quoted 6 lines
net/mptcp/protocol.c +0
-0@@ -2130,8 +2130,10 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)return copied;
net/mptcp/protocol.c static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) · line 2139
Quoted 10 lines
net/mptcp/protocol.c +3
-1do_error: -if (copied) +if (copied) { +__mptcp_push_pending (sk, msg->msg_flags); goto out; + } copied =sk_stream_error (sk, msg->msg_flags, ret); goto out;
[Severity: Low]
The Fixes tag looks off to me. Before 69800e516e96 ("mptcp: propagate fastclose error"), a copy fault in mptcp_sendmsg() already set ret = -EFAULT and jumped straight to out. The out label sat after the if (copied) __mptcp_push_pending() block and returned copied ? : ret.
So with copied > 0, the already queued dfrag was left on rtx_queue without a push even back then. 69800e516e96 only introduced do_error to pass ret through sk_stream_error() when copied == 0. It kept the existing if (copied) goto out; behaviour.
As far as I can tell, skipping the push on a partial copy error goes back to d9ca1de8c0cd ("mptcp: move page frag allocation in mptcp_sendmsg()"). That commit made mptcp_sendmsg() queue everything first and only push after the loop.
With the current tag, stable tooling would miss kernels that have d9ca1de8c0cd but not 69800e516e96.
Could you double check, and if you agree, point the Fixes tag at d9ca1de8c0cd instead?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116-net-mptcp-misc-fixes-7-4-rc4-v1-0-bf7656de653e%40kernel.org
Matthieu Baerts
maintainerRe: [PATCH net 2/7] mptcp: push pending data after a sendmsg copy fault
Hello,
Quoted 8 lines · On 17/11/2026 23:29, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] mptcp: Fixes trailer in commit message cites
69800e516e96instead ofd9ca1de8c0cd
Correct, before 69800e516e96, the push was already skipped after a partial copy. The right tag is:
Do I need to send a v2 for that? If yes, can we please just drop this patch?
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Matthieu Baerts (NGI0)
maintainerPATCH 3/7 mptcp: use sk instead of casting msk in check_fully_established()
In reply to Matthieu Baerts (NGI0)The MPTCP socket is cast to a struct sock in check_fully_established(), to take its data lock. The next commits need it more, to push the pending data.
Add a local 'sk' variable instead of casting msk each time: no functional change.
The 'Fixes' tag here below is the same as the one from the next
commits: this patch is needed to fix the issues introduced by this commit ID.
--- net/mptcp/options.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/mptcp/options.c +4 -2
@@ -982,6 +982,8 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk,struct sk_buff *skb, struct mptcp_options_received *mp_opt) { + struct sock *sk = (struct sock *)msk; +/* here we can process OoO, in-window pkts, only in-sequence 4th ack * will make the subflow fully established */
@@ -1043,9 +1045,9 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk,if (mp_opt->deny_join_id0)WRITE_ONCE (msk->pm.remote_deny_join_id0, true); -mptcp_data_lock ((struct sock *)msk); +mptcp_data_lock (sk);__mptcp_subflow_fully_established (msk, subflow, mp_opt); -mptcp_data_unlock ((struct sock *)msk); +mptcp_data_unlock (sk); check_notify:/* if the subflow is not already linked into the conn_list, we can't
Signature · 1 line
2.55.0
Matthieu Baerts (NGI0)
maintainerPATCH 4/7 mptcp: push queued data on passive TFO subflows becoming established
In reply to Matthieu Baerts (NGI0)With TCP Fast Open, the data written by an MPTCP server before the 3rd ACK is not sent when this ACK arrives, but only when another event triggers a push, e.g. new data from the peer. With a request/response protocol, the client waits for the reply, which can then stay stuck.
A SYN with a valid TFO cookie creates a child socket right away, which can be accepted while its subflow is still in the SYN_RECV state. The MPTCP socket is already in the ESTABLISHED state: send() puts the data in its write queue, but this data cannot be pushed to the subflow before it is established, see __mptcp_subflow_active(). When the third ACK, with the MP_CAPABLE option, arrives, check_fully_established() marks the subflow as fully established, but nothing pushes the pending data:
this ACK has no DSS option, so ack_update_msk() is not called.
The fix used here is to push the pending data when a passive TFO subflow becomes fully established. Checking subflow->is_mptfo is not enough:
since commit e00b63056fb4 ("mptcp: fastopen: only mark MPTFO subflows with SYN data"), it is not set when the SYN has no data, while a child is also created in this case. syn_fastopen_child is then used instead.
This issue has been reported by a user of proxies over MPTCP: the clients put their requests in the SYN, and the replies from the targets close to the server were stuck. It has been reproduced with new Packetdrill tests, where the server writes data before the third ACK, after a SYN with and without data. Without this patch, and before the earlier commit "mptcp: arm the rtx timer if a push leaves data behind", this data was not sent:
server-tfo-write-before-3rd-ack.pkt:24: error handling packet: Timed out waiting for packet
Since this earlier commit, this data is sent, but only when the MPTCP retransmission timer fires, here after one second, as the tests increase its interval:
server-tfo-write-before-3rd-ack.pkt:24: error handling packet: timing error: expected outbound packet at 0.237174 sec but happened at 1.181857 sec; tolerance 0.100000 sec
--- net/mptcp/options.c | 2 ++ 1 file changed, 2 insertions(+)
net/mptcp/options.c +2 -0
@@ -1047,6 +1047,8 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk,mptcp_data_lock (sk);__mptcp_subflow_fully_established (msk, subflow, mp_opt); +if (tcp_sk (ssk)->syn_fastopen_child) +__mptcp_check_push (sk, ssk);mptcp_data_unlock (sk); check_notify:
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH net 4/7] mptcp: push queued data on passive TFO subflows becoming established
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message of "mptcp: push queued data on passive TFO subflows becoming established" describes behaviour that depends on an…
--
mptcp: push queued data on passive TFO subflows becoming established
With TCP Fast Open, data written by an MPTCP server before the third ACK could stay queued after that ACK, because the ACK carries MP_CAPABLE without DSS, so ack_update_msk() is never called. This commit makes check_fully_established() call __mptcp_check_push() when a subflow becomes fully established on a passive TFO child (syn_fastopen_child), so the data is pushed at that point.
Quoted 9 lines
Without this patch, and before the
earlier commit "mptcp: arm the rtx timer if a push leaves data behind", this data was not sent:server-tfo-write-before-3rd-ack.pkt:24: error handling packet: Timed out waiting for packet
Since this earlier commit, this data is sent, but only when the MPTCP retransmission timer fires, here after one second, as the tests increase its interval:
[Severity: Low]
Which tree is "mptcp: arm the rtx timer if a push leaves data behind" in?
That commit doesn't seem to be present here, either at this commit or at the end of the series. The following patch, "mptcp: push queued data on subflows falling back at the handshake", refers to it the same way. Neither message gives a SHA or a lore link for it.
In net/mptcp/protocol.c, __mptcp_push_pending() still arms the rtx timer only when data was copied:
net/mptcp/protocol.c:__mptcp_push_pending() {
...
/* Avoid scheduling the rtx timer if no data has been pushed; the timer
* will be updated on positive acks by __mptcp_cleanup_una().
*/
if (copied) {
if (!mptcp_rtx_timer_pending(sk))
mptcp_reset_rtx_timer(sk);
mptcp_check_send_data_fin(sk);
}
}__mptcp_subflow_push_pending() also arms it only inside its if (copied) block.
So in this tree, without this patch, the data would hit the "Timed out waiting for packet" case. It would not be sent late, after the one second delay.
Could the changelog say where that commit lives, for example with a SHA or a lore link? That would let stable backporters find the dependency and see how the two changes are ordered.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116-net-mptcp-misc-fixes-7-4-rc4-v1-0-bf7656de653e%40kernel.org
Matthieu Baerts
maintainerRe: [PATCH net 4/7] mptcp: push queued data on passive TFO subflows becoming established
Hello,
Quoted 5 lines · On 17/11/2026 23:29, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
(...)
Quoted 4 lines
Quoted 4 lines
Without this patch, and before the
earlier commit "mptcp: arm the rtx timer if a push leaves data behind", this data was not sent:
Quoted 8 lines
Quoted 5 lines
server-tfo-write-before-3rd-ack.pkt:24: error handling packet: Timed out waiting for packet
Since this earlier commit, this data is sent, but only when the MPTCP retransmission timer fires, here after one second, as the tests increase its interval:
[Severity: Low]
Which tree is "mptcp: arm the rtx timer if a push leaves data behind" in?
Arf, I forgot to remove that when I cherry-picked this fix. That's a detail, it's a fix pending on the MPTCP ML, not applied yet:
https://lore.kernel.org/[email protected]
There is no dependency: in this tree, the data was never sent, as described for the case "before this earlier commit". I suggest ignoring that, it's not directly linked, and this patch will come soon.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Matthieu Baerts (NGI0)
maintainerPATCH 5/7 mptcp: push queued data on subflows falling back at the handshake
In reply to Matthieu Baerts (NGI0)With TCP Fast Open, the data written by an MPTCP server before the 3rd ACK is not sent when this ACK arrives without MPTCP options, but only when another event triggers a push, e.g. new data from the peer.
The previous commit pushes this data when the third ACK, with the MP_CAPABLE option, makes a passive TFO subflow fully established. If this ACK has no MPTCP options, e.g. because a middlebox removed them, check_fully_established() falls back to TCP, and returns before this push. The fallback case of mptcp_incoming_options(), which pushes the pending data, is only reached with the next packets.
The fix used here is to push the pending data after this fallback too. Not only for the passive TFO subflows: data can also be pending on the client side, when the first ACK from the server has no MPTCP options, e.g. if the window announced by the SYN+ACK was too small for it. Same here, this data was then only sent when another event triggered a push.
This issue has been found by an AI code review agent (Clashiko), while reviewing an earlier version of the previous commit. It has been reproduced with a new Packetdrill test, where the MPTCP options are removed from the third ACK. Without this patch, and before the earlier commit "mptcp: arm the rtx timer if a push leaves data behind", this data was not sent:
server-tfo-fallback-write-before-3rd-ack.pkt:26: error handling packet: Timed out waiting for packet
Since this earlier commit, this data is sent, but only when the MPTCP retransmission timer fires, here after one second, as the test increases its interval:
server-tfo-fallback-write-before-3rd-ack.pkt:26: error handling packet: timing error: expected outbound packet at 0.235869 sec but happened at 1.144189 sec; tolerance 0.100000 sec
The client side case has been reported by Sashiko, while reviewing an earlier version of this commit, and confirmed with another new Packetdrill test, where the client writes more data than the window of the SYN+ACK, before an ACK without MPTCP options. Without this patch:
v1_connect_fallback_pending_data.pkt:30: error handling packet: timing error: expected outbound packet at 0.251394 sec but happened at 1.195904 sec; tolerance 0.100000 sec
Two Fixes tags: the passive TFO case comes from the first commit, and the client side one from the second one.
--- net/mptcp/options.c | 4 ++++ 1 file changed, 4 insertions(+)
net/mptcp/options.c +4 -0
@@ -1035,6 +1035,10 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk,MPTCP_INC_STATS (sock_net (ssk),MPTCP_MIB_FALLBACKFAILED ); goto reset; } +/* this ACK will not reach the fallback path: push from here */ +mptcp_data_lock (sk); +__mptcp_check_push (sk, ssk); +mptcp_data_unlock (sk);return false; }
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH net 5/7] mptcp: push queued data on subflows falling back at the handshake
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] mptcp: incomplete fallback cleanup in check_fully_established() - [Medium] mptcp: spurious data…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] mptcp: incomplete fallback cleanup in check_fully_established()
- [Medium] mptcp: spurious data push on incoming TCP RST in check_fully_established()
--
commit c7b2d96469f365f0990144845b235e48664597ea
Author: Matthieu Baerts (NGI0) <[email protected]>
mptcp: push queued data on subflows falling back at the handshake
This commit pushes pending MPTCP data in check_fully_established() when a subflow falls back to TCP because the first packet after the handshake carries no MP_CAPABLE option.
Quoted 5 lines
net/mptcp/options.c +0
-0
net/mptcp/options.c static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk, · line 1043
Quoted 9 lines
net/mptcp/options.c +4
-0@@ -1035,6 +1035,10 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk,MPTCP_INC_STATS (sock_net (ssk),MPTCP_MIB_FALLBACKFAILED ); goto reset; } +/* this ACK will not reach the fallback path: push from here */ +mptcp_data_lock (sk); +__mptcp_check_push (sk, ssk); +mptcp_data_unlock (sk);return false; }
[Severity: Medium]
Does returning false here after only calling __mptcp_check_push() leave sent and newly pushed dfrags stranded in msk->rtx_queue?
When check_fully_established() returns false, mptcp_incoming_options() returns immediately without running the rest of its fallback path:
net/mptcp/options.c:mptcp_incoming_options() {
...
if (__mptcp_check_fallback(msk)) {
mptcp_data_lock(subflow->conn);
if (sk_stream_memory_free(sk))
__mptcp_check_push(subflow->conn, sk);
/* on fallback we just need to ignore the msk-level snd_una, as
* this is really plain TCP
*/
__mptcp_snd_una_update(msk, READ_ONCE(msk->snd_nxt));
__mptcp_data_acked(subflow->conn);
mptcp_data_unlock(subflow->conn);
return !mptcp_over_limit(subflow->conn, sk, skb);
}
...
if (!check_fully_established(msk, sk, subflow, skb, &mp_opt))
return sk->sk_state != TCP_CLOSE;
}Because __mptcp_snd_una_update() and __mptcp_data_acked() are skipped, msk->snd_una is not advanced to msk->snd_nxt and dfrags in msk->rtx_queue are not cleaned up or uncharged from sk->sk_wmem_queued until a later packet arrives. If a sender fills sk->sk_sndbuf within the SYN+ACK window and the peer's pure ACK without MPTCP options acknowledges all in-flight TCP data while waiting for more payload, ssk's write queue empties while sk->sk_wmem_queued on msk stays full and writers blocked in sk_stream_wait_memory() or poll(POLLOUT) stall indefinitely. Also, if the packet triggering fallback carries payload, mptcp_over_limit() is bypassed.
[Severity: Medium]
Can this push queued data onto ssk in response to an incoming TCP RST?
When an in-sequence TCP RST arrives before the subflow is fully established, tcp_validate_incoming() -> tcp_reset() calls mptcp_incoming_options() while ssk->sk_state is still TCP_ESTABLISHED, before tcp_done_with_error() closes the subflow. Because a RST carries no MP_CAPABLE option, check_fully_established() falls back and calls __mptcp_check_push(), transmitting queued data from msk->rtx_queue on the subflow right before it is reset.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261116-net-mptcp-misc-fixes-7-4-rc4-v1-0-bf7656de653e@kernel.org?part=5
[email protected]
AI reviewRe: [PATCH net 5/7] mptcp: push queued data on subflows falling back at the handshake
In reply to Matthieu Baerts (NGI0)Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] check_fully_established() (net/mptcp/options.c) now pushes pending MPTCP data in its fallback branch every time that branch runs,…
--
mptcp: push queued data on subflows falling back at the handshake
This commit pushes pending MPTCP data from check_fully_established() when a subflow that is not yet fully established falls back to TCP, because the first established packet carries no MP_CAPABLE option. This covers both passive TFO subflows and clients with data held back by a small SYN+ACK window.
Quoted 5 lines
net/mptcp/options.c +0
-0
net/mptcp/options.c static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk, · line 1043
Quoted 9 lines
net/mptcp/options.c +4
-0@@ -1035,6 +1035,10 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk,MPTCP_INC_STATS (sock_net (ssk),MPTCP_MIB_FALLBACKFAILED ); goto reset; } +/* this ACK will not reach the fallback path: push from here */ +mptcp_data_lock (sk); +__mptcp_check_push (sk, ssk); +mptcp_data_unlock (sk);return false; }
[Severity: Low]
Can this push also run while an incoming RST is being processed?
tcp_reset() calls into MPTCP before it tears the subflow down:
net/ipv4/tcp_input.c:tcp_reset() {
...
if (sk_is_mptcp(sk))
mptcp_incoming_options(sk, skb);
...
tcp_done_with_error(sk, err);
}Take an active client whose mp_capable subflow has sent the third ACK but has not yet received a DSS DATA_ACK, so subflow->fully_established is still 0. Suppose an RST arrives with seq == rcv_nxt == ssn_offset + 1. tcp_validate_incoming() accepts it and calls tcp_reset().
A plain RST from a middlebox, or an RST that only carries MP_RST, has no OPTIONS_MPTCP_MPC. So check_fully_established() enters this fallback branch, and mptcp_try_fallback() succeeds.
The new code then goes through:
__mptcp_check_push()
__mptcp_subflow_push_pending()
mptcp_sched_get_send()
__subflow_push_pending()
tcp_push()
mptcp_reset_rtx_timer()In fallback mode, mptcp_sched_get_send() only checks __tcp_can_send(msk->first) and sk_stream_memory_free(). The subflow is still TCP_ESTABLISHED at this point, so it gets picked.
Right after this returns, tcp_done_with_error() purges the subflow write queue and closes the subflow.
Usually TCP's own snd_wnd keeps the data off the wire. The work is still wasted, though: dfrags are copied into a queue that is purged at once, msk->snd_nxt moves forward, and the msk rtx timer is armed during teardown.
What if the TCP window allows more than the msk window? For example, data could have been left behind by an allocation failure, or snd_wnd could have been updated by a segment without a DSS. Could data segments then go on the wire after a valid RST was accepted?
The fallback block at the top of mptcp_incoming_options() already does this for an msk that fell back earlier. This patch makes the same thing reachable from the not-yet-fully-established case.
The comment says "this ACK", but the packet here can be an RST. Would it make sense to skip the push when the skb has the RST flag set?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116-net-mptcp-misc-fixes-7-4-rc4-v1-0-bf7656de653e%40kernel.org
Matthieu Baerts
maintainerRe: [PATCH net 5/7] mptcp: push queued data on subflows falling back at the handshake
Hello,
Quoted 5 lines · On 17/11/2026 23:29, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
(...)
Quoted 2 lines
[Severity: Low]
Can this push also run while an incoming RST is being processed?
This is not new: the fallback block at the top of mptcp_incoming_options already does the same push, RST or not. At worst, data is queued then purged, or sent within the TCP window just before the reset, and the peer replies with a reset. This is harmless. If really needed (I don't think so) a follow-up patch can be sent, but to -next I suppose.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Matthieu Baerts (NGI0)
maintainerPATCH 6/7 mptcp: don't send a FIN before the pending data on fallback
In reply to Matthieu Baerts (NGI0)When an MPTCP connection falls back to TCP after having been shut down, the data that is still in the write queue of the MPTCP socket is lost:
a FIN is sent at fallback time, and this data cannot be sent after it. This can happen with TCP Fast Open (TFO), when a server writes data and shuts the connection down before the third ACK, and this ACK has no MPTCP options.
When the MPTCP socket has been shut down, mptcp_try_fallback() also shuts the subflow down: if the DATA_FIN had already been sent, nothing would send a FIN on this subflow otherwise. The commit introducing this only considered the case where all the data had already been pushed to the subflow.
The fix used here is to only shut the subflow down at fallback time if no new data is pending, i.e. if all the data before the DATA_FIN has already been sent. Otherwise, mptcp_check_send_data_fin() will do it once this data has been pushed, e.g. by the previous commit. Pending data that has been reinjected, e.g. after the failure of another subflow, is not new: it is already in this subflow.
This issue has been found by an AI code review agent, while reviewing the code of the previous commit, and confirmed with a new Packetdrill test, where the server writes data and shuts the connection down before the third ACK, from which the MPTCP options are removed. Without this patch, a FIN was sent right after this ACK, and the data was never sent:
inbound injected packet: 0.240127 . 501:501(0) ack 4103187975 win 450 outbound sniffed packet: 0.240207 F. 4103187975:4103187975(0) ack 501 win 1050 outbound sniffed packet: 1.347800 F. 4103187975:4103187975(0) ack 501 win 1050 outbound sniffed packet: 2.499829 F. 4103187975:4103187975(0) ack 501 win 1050 outbound sniffed packet: 4.739843 F. 4103187975:4103187975(0) ack 501 win 1050
server-tfo-fallback-shutdown-before-3rd-ack.pkt:27: error handling packet: Timed out waiting for packet
--- net/mptcp/protocol.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/mptcp/protocol.h +5 -1
@@ -1333,7 +1333,11 @@ static inline bool mptcp_try_fallback(struct sock *ssk, int fb_mib) msk =mptcp_sk (sk);if (!__mptcp_try_fallback (msk, fb_mib))return false; -if (READ_ONCE (msk->snd_data_fin_enable) && !(ssk->sk_shutdown &SEND_SHUTDOWN )) { + +/* no FIN before new data: see mptcp_check_send_data_fin() */ +if (READ_ONCE (msk->snd_data_fin_enable) && + !before64 (READ_ONCE (msk->snd_nxt) +1 ,READ_ONCE (msk->write_seq)) && + !(ssk->sk_shutdown &SEND_SHUTDOWN )) {gfp_t saved_allocation = ssk->sk_allocation;/* we are in a atomic (BH) scope, override ssk default for data
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH net 6/7] mptcp: don't send a FIN before the pending data on fallback
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] mptcp: unadvanced snd_nxt in mptcp_try_fallback() with reinjected data - [Medium] mptcp: missing…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] mptcp: unadvanced snd_nxt in mptcp_try_fallback() with reinjected data
- [Medium] mptcp: missing pending data push after fallback in subflow_check_data_avail()
--
commit 7f5ccb63dcef4623a742b8e41a51358adb229738
Author: Matthieu Baerts (NGI0) <[email protected]>
mptcp: don't send a FIN before the pending data on fallback
This commit avoids shutting down the subflow at fallback time when unsent data is still pending in the MPTCP write queue, so that a TCP FIN is not sent before the pending data.
Quoted 7 lines
net/mptcp/protocol.h +0
-0@@ -1333,7 +1333,11 @@ static inline bool mptcp_try_fallback(struct sock *ssk, int fb_mib) msk =mptcp_sk (sk);if (!__mptcp_try_fallback (msk, fb_mib))
net/mptcp/protocol.h static inline bool mptcp_try_fallback(struct sock *ssk, int fb_mib) · line 1343
Quoted 10 lines
net/mptcp/protocol.h +5
-1return false; -if (READ_ONCE (msk->snd_data_fin_enable) && !(ssk->sk_shutdown &SEND_SHUTDOWN )) { + +/* no FIN before new data: see mptcp_check_send_data_fin() */ +if (READ_ONCE (msk->snd_data_fin_enable) && + !before64 (READ_ONCE (msk->snd_nxt) +1 ,READ_ONCE (msk->write_seq)) && + !(ssk->sk_shutdown &SEND_SHUTDOWN )) {gfp_t saved_allocation = ssk->sk_allocation;/* we are in a atomic (BH) scope, override ssk default for data
[Severity: Medium]
Can mptcp_try_fallback() leave msk->snd_nxt at msk->write_seq - 1 when reinjected data is still in msk->first_pending?
If an unjoined additional subflow closes and __mptcp_close_ssk() calls __mptcp_retransmit_pending_data(), msk->first_pending is reset while msk->snd_nxt stays at msk->write_seq. If the application then shuts down the write side before the initial subflow re-pushes that reinjected data, __mptcp_wr_shutdown() increments msk->write_seq by 1, and mptcp_check_send_data_fin() returns early without advancing msk->snd_nxt:
net/mptcp/protocol.c:mptcp_check_send_data_fin() {
if (!msk->snd_data_fin_enable || msk->snd_nxt + 1 != msk->write_seq ||
mptcp_send_head(sk))
return;
WRITE_ONCE(msk->snd_nxt, msk->write_seq);
...
}When mptcp_try_fallback() runs next, msk->snd_nxt + 1 == msk->write_seq holds, so it sets SEND_SHUTDOWN on ssk without advancing msk->snd_nxt to msk->write_seq. Setting SEND_SHUTDOWN stops __subflow_push_pending() from pushing the reinjected data and calling mptcp_check_send_data_fin(). On subsequent packets, mptcp_incoming_options() only advances msk->snd_una to READ_ONCE(msk->snd_nxt) (msk->write_seq - 1), so mptcp_pending_data_fin_ack() never sees msk->snd_una == msk->write_seq and a half-closed MPTCP socket stays stuck in TCP_FIN_WAIT1.
[Severity: Medium]
Does skipping tcp_shutdown() here stall connection termination when fallback is triggered after the handshake in subflow_check_data_avail() or mptcp_dss_corruption()?
When unsent data is queued and the socket has been shut down, mptcp_try_fallback() now defers the FIN, relying on the caller to push the pending data so mptcp_check_send_data_fin() can send the FIN afterward. Unlike check_fully_established(), subflow_check_data_avail() and mptcp_dss_corruption() run after mptcp_incoming_options() has already finished (and returned early when OPTION_MPTCP_DSS was absent), and neither calls __mptcp_check_push() after mptcp_try_fallback():
net/mptcp/subflow.c:subflow_check_data_avail() {
...
if (!mptcp_try_fallback(ssk, MPTCP_MIB_DSSFALLBACK)) {
/* fatal protocol error, close the socket */
subflow->reset_transient = 0;
subflow->reset_reason = MPTCP_RST_EMPTCP;
goto reset;
}
...
}If the head of msk->rtx_queue also has unacknowledged already-sent data, __mptcp_retrans() sees the fallback in __mptcp_push_retrans() and jumps to clear_scheduled without calling mptcp_check_and_set_pending(sk). If the peer sends no more packets, the pending data and the deferred FIN are never transmitted.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261116-net-mptcp-misc-fixes-7-4-rc4-v1-0-bf7656de653e@kernel.org?part=6
[email protected]
AI reviewRe: [PATCH net 6/7] mptcp: don't send a FIN before the pending data on fallback
In reply to Matthieu Baerts (NGI0)Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] The new 'no FIN before new data' check in mptcp_try_fallback() (net/mptcp/protocol.h) is not reliable.
- [Medium] mptcp: missing pending data push after fallback in subflow_check_data_avail()
--
mptcp: don't send a FIN before the pending data on fallback
After this change, mptcp_try_fallback() shuts the subflow down at fallback time only when no new data is pending before the DATA_FIN. Otherwise, mptcp_check_send_data_fin() is expected to shut the subflow down once that data has been pushed. This stops a TCP FIN from going out ahead of data still in the MPTCP write queue, as in the TFO server case.
Quoted 5 lines
net/mptcp/protocol.h +0
-0
net/mptcp/protocol.h static inline bool mptcp_try_fallback(struct sock *ssk, int fb_mib) · line 1340
Quoted 9 lines
net/mptcp/protocol.h +5
-1@@ -1333,7 +1333,11 @@ static inline bool mptcp_try_fallback(struct sock *ssk, int fb_mib) msk =mptcp_sk (sk);if (!__mptcp_try_fallback (msk, fb_mib))return false; -if (READ_ONCE (msk->snd_data_fin_enable) && !(ssk->sk_shutdown &SEND_SHUTDOWN )) { + +/* no FIN before new data: see mptcp_check_send_data_fin() */ +if (READ_ONCE (msk->snd_data_fin_enable) && + !before64 (READ_ONCE (msk->snd_nxt) +1 ,READ_ONCE (msk->write_seq)) && + !(ssk->sk_shutdown &SEND_SHUTDOWN )) {
[Severity: Medium]
With this change, the subflow FIN is deferred while new data is still pending, and mptcp_check_send_data_fin() is expected to send it once that data has been pushed. check_fully_established() now calls __mptcp_check_push() after a successful fallback, so that path is covered. What about the other mptcp_try_fallback() callers?
subflow_check_data_avail() falls back on MAPPING_NODSS and MAPPING_DUMMY:
net/mptcp/subflow.c:subflow_check_data_avail() {
...
if (!mptcp_try_fallback(ssk, MPTCP_MIB_DSSFALLBACK)) {
...
}mptcp_dss_corruption() does the same on a corrupted mapping:
net/mptcp/protocol.c:mptcp_dss_corruption() {
...
if (!mptcp_try_fallback(ssk, MPTCP_MIB_DSSCORRUPTIONFALLBACK)) {
...
}In both cases, mptcp_incoming_options() has already run for this packet while MPTCP_FALLBACK_DONE was still clear. Without a DSS option, it returns early, before ack_update_msk() and __mptcp_check_push() are reached. Neither caller pushes the pending data once the fallback has succeeded.
Before this patch, the FIN was sent here unconditionally. The data was lost, but the connection could still be closed. Now the FIN is skipped. If the peer doesn't send anything else, what pushes the data from msk->first_pending and then calls mptcp_check_send_data_fin()?
The retransmit timer doesn't seem to help either. If there is unacked data at the head of the rtx_queue, __mptcp_push_retrans() returns -1 on a fallen-back msk, and __mptcp_retrans() jumps to clear_scheduled:
net/mptcp/protocol.c:__mptcp_retrans() {
...
/* Can fail only in case of fallback. */
len = __mptcp_push_retrans(sk, dfrag, retrans_seq);
if (len < 0)
goto clear_scheduled;
...
}This skips mptcp_check_and_set_pending(sk), so the pending data isn't scheduled from there either.
Couldn't the connection then be left with both the pending data and the deferred FIN stuck, so the shutdown never completes? Should subflow_check_data_avail() and mptcp_dss_corruption() also trigger a push after a successful fallback, like check_fully_established() does? Or is another path expected to flush this data?
[Severity: Medium]
Is this lockless check ordered against the writer?
mptcp_try_fallback() can run in BH context with only the ssk lock held. One example is check_fully_established(), when the 3rd ACK arrives without MPTCP options:
net/mptcp/options.c:check_fully_established() {
...
if (!mptcp_try_fallback(ssk, MPTCP_MIB_MPCAPABLEDATAFALLBACK)) {
...
}The writer is __mptcp_wr_shutdown(), called from mptcp_shutdown() and mptcp_close(). It holds only the msk socket lock, not the ssk lock or msk->fallback_lock:
net/mptcp/protocol.c:__mptcp_wr_shutdown() {
...
WRITE_ONCE(msk->write_seq, msk->write_seq + 1);
WRITE_ONCE(msk->snd_data_fin_enable, 1);
...
}Nothing orders these two stores. Nothing orders the three READ_ONCE() loads in mptcp_try_fallback() either. The spin_lock_bh() on msk->fallback_lock in __mptcp_try_fallback() doesn't help, because the writer never takes that lock.
On a weakly ordered CPU such as arm64 or POWER, could the BH reader see snd_data_fin_enable == 1 together with the old write_seq?
Suppose exactly one byte of new data is still unsent, so snd_nxt + 1 equals the old write_seq. The new check then evaluates to true, and tcp_shutdown(ssk) sends the FIN before that byte.
After that, mptcp_check_send_data_fin() returns early on the writer side:
net/mptcp/protocol.c:mptcp_check_send_data_fin() {
...
if (!msk->snd_data_fin_enable || msk->snd_nxt + 1 != msk->write_seq ||
mptcp_send_head(sk))
return;
...
}The byte can't be pushed later either. The subflow is now in FIN_WAIT1 or LAST_ACK, so __tcp_can_send() fails in __mptcp_subflow_active().
Wouldn't this truncate the stream in the same way this patch is meant to prevent, only within a narrower window? The later patch in the series, "mptcp: fix dummy mapping of overlapping segments", doesn't touch protocol.h or protocol.c, so the window would still be open at the end of the series.
Would it close the window to publish snd_data_fin_enable with smp_store_release() after the write_seq update, and read it with smp_load_acquire() in mptcp_try_fallback()? An smp_wmb()/smp_rmb() pair would also work.
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116-net-mptcp-misc-fixes-7-4-rc4-v1-0-bf7656de653e%40kernel.org
Matthieu Baerts
maintainerRe: [PATCH net 6/7] mptcp: don't send a FIN before the pending data on fallback
Hello,
Quoted 7 lines · On 17/11/2026 23:29, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong.
Please see below.
(...)
Quoted 63 lines
Quoted 5 lines
net/mptcp/protocol.h +0
-0net/mptcp/protocol.h static inline bool mptcp_try_fallback(struct sock *ssk, int fb_mib) · line 1340
Quoted 9 lines
net/mptcp/protocol.h +5
-1@@ -1333,7 +1333,11 @@ static inline bool mptcp_try_fallback(struct sock *ssk, int fb_mib) msk =mptcp_sk (sk);if (!__mptcp_try_fallback (msk, fb_mib))return false; -if (READ_ONCE (msk->snd_data_fin_enable) && !(ssk->sk_shutdown &SEND_SHUTDOWN )) { + +/* no FIN before new data: see mptcp_check_send_data_fin() */ +if (READ_ONCE (msk->snd_data_fin_enable) && + !before64 (READ_ONCE (msk->snd_nxt) +1 ,READ_ONCE (msk->write_seq)) && + !(ssk->sk_shutdown &SEND_SHUTDOWN )) {[Severity: Medium]
With this change, the subflow FIN is deferred while new data is still pending, andmptcp_check_send_data_fin()is expected to send it once that data has been pushed.check_fully_established()now calls__mptcp_check_push()after a successful fallback, so that path is covered. What about the othermptcp_try_fallback()callers?
subflow_check_data_avail()falls back onMAPPING_NODSSandMAPPING_DUMMY:net/mptcp/subflow.c:subflow_check_data_avail() { ... if (!mptcp_try_fallback(ssk, MPTCP_MIB_DSSFALLBACK)) { ... }
mptcp_dss_corruption()does the same on a corrupted mapping:net/mptcp/protocol.c:mptcp_dss_corruption() { ... if (!mptcp_try_fallback(ssk, MPTCP_MIB_DSSCORRUPTIONFALLBACK)) { ... }In both cases,
mptcp_incoming_options()has already run for this packet whileMPTCP_FALLBACK_DONEwas still clear. Without a DSS option, it returns early, beforeack_update_msk()and__mptcp_check_push()are reached. Neither caller pushes the pending data once the fallback has succeeded.Before this patch, the FIN was sent here unconditionally. The data was lost, but the connection could still be closed. Now the FIN is skipped. If the peer doesn't send anything else, what pushes the data from
msk->first_pendingand then callsmptcp_check_send_data_fin()?The retransmit timer doesn't seem to help either. If there is unacked data at the head of the
rtx_queue,__mptcp_push_retrans()returns -1 on a fallen-back msk, and__mptcp_retrans()jumps toclear_scheduled:net/mptcp/protocol.c:__mptcp_retrans() { ... /* Can fail only in case of fallback. */ len = __mptcp_push_retrans(sk, dfrag, retrans_seq); if (len < 0) goto clear_scheduled; ... }
Quoted 8 lines
This skips
mptcp_check_and_set_pending(sk), so the pending data isn't scheduled from there either.Couldn't the connection then be left with both the pending data and the deferred FIN stuck, so the shutdown never completes? Should
subflow_check_data_avail()andmptcp_dss_corruption()also trigger a push after a successful fallback, likecheck_fully_established()does? Or is another path expected to flush this data?
Somehow pre-existing: Before this patch, this pending data was lost: the peer silently got a truncated stream. Now, the data and the FIN are sent at the next push, e.g. on the next ACK or window update from the peer. This is the same as for pending data without shutdown, which was already not pushed after these fallbacks: this is a pre-existing issue, not a regression. It can be handled in a follow-up, if a stall can be reproduced, but I didn't manage to reproduce it so far.
Quoted 46 lines
[Severity: Medium]
Is this lockless check ordered against the writer?
mptcp_try_fallback()can run in BH context with only the ssk lock held. One example ischeck_fully_established(), when the 3rd ACK arrives without MPTCP options:net/mptcp/options.c:check_fully_established() { ... if (!mptcp_try_fallback(ssk, MPTCP_MIB_MPCAPABLEDATAFALLBACK)) { ... }The writer is
__mptcp_wr_shutdown(), called frommptcp_shutdown()andmptcp_close(). It holds only the msk socket lock, not the ssk lock ormsk->fallback_lock:net/mptcp/protocol.c:__mptcp_wr_shutdown() { ... WRITE_ONCE(msk->write_seq, msk->write_seq + 1); WRITE_ONCE(msk->snd_data_fin_enable, 1); ... }Nothing orders these two stores. Nothing orders the three
READ_ONCE()loads inmptcp_try_fallback()either. Thespin_lock_bh()onmsk->fallback_lockin__mptcp_try_fallback()doesn't help, because the writer never takes that lock.On a weakly ordered CPU such as arm64 or POWER, could the BH reader see
snd_data_fin_enable== 1 together with the oldwrite_seq?Suppose exactly one byte of new data is still unsent, so
snd_nxt+ 1 equals the oldwrite_seq. The new check then evaluates to true, andtcp_shutdown(ssk)sends the FIN before that byte.After that,
mptcp_check_send_data_fin()returns early on the writer side:net/mptcp/protocol.c:mptcp_check_send_data_fin() { ... if (!msk->snd_data_fin_enable || msk->snd_nxt + 1 != msk->write_seq || mptcp_send_head(sk)) return; ... }
Quoted 5 lines
The byte can't be pushed later either. The subflow is now in
FIN_WAIT1orLAST_ACK, so__tcp_can_send()fails in__mptcp_subflow_active().Wouldn't this truncate the stream in the same way this patch is meant to prevent, only within a narrower window?
This is theoretical: it needs a weakly ordered CPU, a shutdown racing with a fallback, and exactly one byte left unsent. Without this patch, the stream is always truncated in this case, so not a regression, and I don't think it is worth blocking this patch for this theoretical reason.
Quoted 4 lines
Would it close the window to publish
snd_data_fin_enablewithsmp_store_release()after thewrite_sequpdate, and read it withsmp_load_acquire()inmptcp_try_fallback()? An smp_wmb()/smp_rmb() pair would also work.
A release/acquire pair is cheap: I can send a follow-up later on.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Matthieu Baerts (NGI0)
maintainerPATCH 7/7 mptcp: fix dummy mapping of overlapping segments
In reply to Matthieu Baerts (NGI0)From: Geliang Tang <[email protected]>
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)
[ Combine the commit messages of Geliang's [1] and Chris's versions.
Commit message: how the issue was found, and its symptoms. ]
--- net/mptcp/subflow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/subflow.c +1 -1
@@ -1496,7 +1496,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 -
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH net 7/7] mptcp: fix dummy mapping of overlapping segments
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit's author and the author's sign-off use different email addresses.
--
mptcp: fix dummy mapping of overlapping segments
After a fallback to TCP, subflow_check_data_avail() builds a dummy mapping. This commit computes map_subflow_seq from the first byte of the skb at the head of the receive queue instead of from copied_seq, so that map_subflow_seq and map_seq describe the same byte. Without this, new bytes in a segment that partly overlaps data already received get a DSN that is too low, and they are skipped as old data.
Quoted 1 line
Author: Geliang Tang <[email protected]>
[ ... ]
Quoted 1 line
Signed-off-by Geliang Tang <[email protected]>
[Severity: Low]
This isn't a bug, but the author address and the address in the author's sign-off are different. The author is [email protected], and the only sign-off from Geliang uses [email protected]. No sign-off uses the author address.
scripts/checkpatch.pl reports this as a FROM_SIGN_OFF_MISMATCH warning ("From:/Signed-off-by: email address mismatch"). The names match exactly but the addresses do not, and checkpatch does not look at .mailmap.
.mailmap already maps the two addresses to the same person:
Geliang Tang <[email protected]> <[email protected]>
So this only affects the consistency of the tags. The DCO itself is not in question.
Since this carries Cc: stable, could the author be set to the kylinos.cn address, or the sign-off use [email protected] (changed or added), before the patch is applied?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116-net-mptcp-misc-fixes-7-4-rc4-v1-0-bf7656de653e%40kernel.org
Matthieu Baerts
maintainerRe: [PATCH net 7/7] mptcp: fix dummy mapping of overlapping segments
Hello,
Quoted 5 lines · On 17/11/2026 23:29, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
(...)
Quoted 20 lines
Quoted 1 line
Author: Geliang Tang <[email protected]>
[ ... ]
Quoted 1 line
Signed-off-by Geliang Tang <[email protected]>[Severity: Low]
This isn't a bug, but the author address and the address in the author's sign-off are different. The author is [email protected], and the only sign-off from Geliang uses [email protected]. No sign-off uses the author address.
scripts/checkpatch.plreports this as aFROM_SIGN_OFF_MISMATCHwarning ("From:/Signed-off-by: email address mismatch"). The names match exactly but the addresses do not, and checkpatch does not look at .mailmap..mailmap already maps the two addresses to the same person:
Quoted 8 lines
Geliang Tang <[email protected]> <[email protected]>
So this only affects the consistency of the tags. The DCO itself is not in question.
Since this carries Cc: stable, could the author be set to the kylinos.cn address, or the sign-off use [email protected] (changed or added), before the patch is applied?
False positive: the author is [email protected], see the "From:" line at the top of the email body. [email protected] comes from .mailmap.
This looks like a bug in Clashiko, Sashiko didn't report that.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Matthieu Baerts
maintainerHi Jakub, Paolo,
Quoted 5 lines · On 16/11/2026 23:06, Matthieu Baerts (NGI0) wrote:
Here are some unrelated fixes:
- Patch 1: do not send data beyond the window announced by the peer. A fix for v5.11.
Quoted 8 lines
- Patch 2: push pending data after a sendmsg copy fault. A fix for v6.1.
- Patches 3-6: with TFO, send the data written by a server before the third ACK as soon as this ACK arrives, also in case of fallback to TCP, even if the connection was shut down. Fixes for v6.2 and v5.19.
- Patch 7: after a fallback, fix the dummy mapping of overlapping segments. A fix for v6.19.
TL;DR regarding the AI reviews: they are not blocking (to me): all "Low" except on patch 6, but that's pre-existing and not a regression.
Note that patch 2 should have another Fixes tag (sent in my reply to Clashiko). Sorry for that, Sashiko/Clashiko didn't notice that before. If changing it when applying the patches is causing troubles, could you please drop this patch 2/7 and apply the rest?
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Jakub Kicinski
maintainerQuoted 4 lines · On Wed, 18 Nov 2026 23:05:24 +0100 Matthieu Baerts wrote:
Note that patch 2 should have another Fixes tag (sent in my reply to Clashiko). Sorry for that, Sashiko/Clashiko didn't notice that before. If changing it when applying the patches is causing troubles, could you please drop this patch 2/7 and apply the rest?
Updated the tag when applying. Sorry for missing the PR.
Matthieu Baerts
maintainerHi Jakub,
Quoted 7 lines · Jakub Kicinski
Quoted 4 lines · On Wed, 18 Nov 2026 23:05:24 +0100 Matthieu Baerts wrote:
Note that patch 2 should have another Fixes tag (sent in my reply to Clashiko). Sorry for that, Sashiko/Clashiko didn't notice that before. If changing it when applying the patches is causing troubles, could you please drop this patch 2/7 and apply the rest?
Updated the tag when applying. Sorry for missing the PR.
Thank you for having updated the tag and applied the series. No problem, I saw how long the queue was on Suie yesterday!
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Mon, 16 Nov 2026 23:06:07 +0100 you wrote:
Here are some unrelated fixes:
- Patch 1: do not send data beyond the window announced by the peer. A fix for v5.11.
- Patch 2: push pending data after a sendmsg copy fault. A fix for v6.1.
[...]
Here is the summary with links:
- [net,1/7] mptcp: do not use a raised snd_wnd for the send window
https://git.kernel.org/netdev/net/c/ec7cb74c1a7e - [net,2/7] mptcp: push pending data after a sendmsg copy fault https://git.kernel.org/netdev/net/c/68f465e3d9ce - [net,3/7] mptcp: use sk instead of casting msk in check_fully_established() https://git.kernel.org/netdev/net/c/bb6081907c60 - [net,4/7] mptcp: push queued data on passive TFO subflows becoming established https://git.kernel.org/netdev/net/c/d7c650916aa1 - [net,5/7] mptcp: push queued data on subflows falling back at the handshake https://git.kernel.org/netdev/net/c/595b7d49d4f1 - [net,6/7] mptcp: don't send a FIN before the pending data on fallback https://git.kernel.org/netdev/net/c/d0e88ecfae68 - [net,7/7] mptcp: fix dummy mapping of overlapping segments https://git.kernel.org/netdev/net/c/3d064436b287
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html