Skip to contentSkip to conversation

mptcp: fix recent failed backports (20260919)

PATCH Applied Matthieu Baerts (NGI0) 2 participants 7 messages Sep 19 – Sep 20

Subsystems (3)
lore
Share & tools
lore

Matthieu Baerts (NGI0)

author maintainer
#0 lore raw

cover mptcp: fix recent failed backports (20260919)

The following patches could not be applied without conflicts in this tree:

- 2b0f561f21b2 ("mptcp: avoid unneeded actions on subflow reset")
- 42064de57fb8 ("mptcp: close race between scheduler and state change")
- f3ef03357396 ("mptcp: fix bad accounting in __mptcp_subflow_push_pending()")

Conflicts (if any) have been resolved, and documented in each patch.

Paolo Abeni (3):
mptcp: avoid unneeded actions on subflow reset
mptcp: close race between scheduler and state change
mptcp: fix bad accounting in __mptcp_subflow_push_pending()

 net/mptcp/protocol.c | 13 ++++++++-----
 net/mptcp/protocol.h |  3 ++-
 net/mptcp/subflow.c  | 11 +++++++++++
 3 files changed, 21 insertions(+), 6 deletions(-)
Signature · 1 line
2.55.0
author maintainer
#1 lore raw

PATCH 1/3 mptcp: avoid unneeded actions on subflow reset

From: Paolo Abeni <[email protected]>

commit 2b0f561f21b27c40c91ea4975268a06092bd7e9c upstream.

Once in a blue moon, the mptcp receive path can recursively call mptcp_data_ready() via state change under unlucky error conditions, and then try to hold the data lock again.

Break the recursion loop explicitly checking for the exceptional condition.

Add a new flag instead of using an existing one like 'closing', to exit early in subflow_state_change(), and explicitly flush the RX queue at reset time.

This avoids unneeded processing to check for available data -- calling get_mapping_status() and more on a dying subflow -- but also in error reporting and worker scheduling.

Note that we must consume the currently peeked skb before invoking mptcp_dss_corruption to avoid consuming it again after the eventual reset has freed it.

[ Note: conflict in protocol.c, because commit e0ca4057e0ec ("mptcp:
micro-optimize __mptcp_move_skb()") is not in this version, and is part of a consequent rx path refactor. The conflict is in the context, and is easy to resolve, "done = true" can be moved along without consequences.
Also a conflict in protocol.h, because __unused is at a different number. Decrement the one from this version and add the new flag above.]

---
 net/mptcp/protocol.c |  6 +++---
 net/mptcp/protocol.h |  3 ++-
 net/mptcp/subflow.c  | 11 +++++++++++
 3 files changed, 16 insertions(+), 4 deletions(-)
net/mptcp/protocol.c +3 -3
index 127438ef120e..187e60ab3f77 100644
@@ -747,13 +747,13 @@ static bool __mptcp_move_skbs_from_subflow(struct mptcp_sock *msk,
 				mptcp_dss_corruption(msk, ssk);
 			}
 		} else {
+			sk_eat_skb(ssk, skb);
+			done = true;
+
 			if (unlikely(!fin)) {
 				DEBUG_NET_WARN_ON_ONCE(1);
 				mptcp_dss_corruption(msk, ssk);
 			}
-
-			sk_eat_skb(ssk, skb);
-			done = true;
 		}
 
 		WRITE_ONCE(tp->copied_seq, seq);
net/mptcp/protocol.h +2 -1
index af00d64e61f4..825f77019092 100644
@@ -510,7 +510,8 @@ struct mptcp_subflow_context {
 		valid_csum_seen : 1,        /* at least one csum validated */
 		is_mptfo : 1,	    /* subflow is doing TFO */
 		close_event_done : 1,       /* has done the post-closed part */
-		__unused : 8;
+		resetting : 1,	    /* subflow is resetting */
+		__unused : 7;
 	bool	data_avail;
 	bool	scheduled;
 	bool	pm_listener;	    /* a listener managed by the kernel PM? */
net/mptcp/subflow.c +11 -0
index 798c87987362..8fd3a0328cd2 100644
@@ -421,6 +421,10 @@ void mptcp_subflow_reset(struct sock *ssk)
 	/* must hold: tcp_done() could drop last reference on parent */
 	sock_hold(sk);
 
+	subflow->resetting = 1;
+
+	/* No need to delay the actual close for to-be discarded data. */
+	__skb_queue_purge(&ssk->sk_receive_queue);
 	tcp_send_active_reset(ssk, GFP_ATOMIC);
 	tcp_done(ssk);
 	if (!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &mptcp_sk(sk)->flags))
@@ -1802,6 +1806,13 @@ static void subflow_state_change(struct sock *sk)
 
 	__subflow_state_change(sk);
 
+	/* Rx queue processing is unneeded, error reporting will take place at
+	 * __mptcp_close_ssk() time and subflow reset can't happen in case of
+	 * fallback: subflow_sched_work_if_closed() would be a no-op.
+	 */
+	if (subflow->resetting)
+		return;
+
 	/* as recvmsg() does not acquire the subflow socket for ssk selection
 	 * a fin packet carrying a DSS can be unnoticed if we don't trigger
 	 * the data available machinery here.
Signature · 1 line
2.55.0
maintainer Applied
#2 lore raw

Patch "mptcp: avoid unneeded actions on subflow reset" has been added to the 6.6-stable tree

This is a note to let you know that I've just added the patch titled

mptcp: avoid unneeded actions on subflow reset

to the 6.6-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
mptcp-avoid-unneeded-actions-on-subflow-reset.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From [email protected] Sat Sep 19 22:06:18 2026
From: "Matthieu Baerts (NGI0)" <[email protected]>
Date: Sat, 19 Sep 2026 22:05:56 +0200
Subject: mptcp: avoid unneeded actions on subflow reset
To: [email protected], [email protected], [email protected]
Cc: Paolo Abeni <[email protected]>, [email protected], Xinyang Ge <[email protected]>, "Matthieu Baerts (NGI0)" <[email protected]>, Jakub Kicinski <[email protected]>
Message-ID: <[email protected]>

From: Paolo Abeni <[email protected]>

commit 2b0f561f21b27c40c91ea4975268a06092bd7e9c upstream.

Once in a blue moon, the mptcp receive path can recursively call mptcp_data_ready() via state change under unlucky error conditions, and then try to hold the data lock again.

Break the recursion loop explicitly checking for the exceptional condition.

Add a new flag instead of using an existing one like 'closing', to exit early in subflow_state_change(), and explicitly flush the RX queue at reset time.

This avoids unneeded processing to check for available data -- calling get_mapping_status() and more on a dying subflow -- but also in error reporting and worker scheduling.

Note that we must consume the currently peeked skb before invoking mptcp_dss_corruption to avoid consuming it again after the eventual reset has freed it.

[ Note: conflict in protocol.c, because commit e0ca4057e0ec ("mptcp:
micro-optimize __mptcp_move_skb()") is not in this version, and is part of a consequent rx path refactor. The conflict is in the context, and is easy to resolve, "done = true" can be moved along without consequences.
Also a conflict in protocol.h, because __unused is at a different number. Decrement the one from this version and add the new flag above.]

---
 net/mptcp/protocol.c |    6 +++---
 net/mptcp/protocol.h |    3 ++-
 net/mptcp/subflow.c  |   11 +++++++++++
 3 files changed, 16 insertions(+), 4 deletions(-)
net/mptcp/protocol.c +3 -3
@@ -747,13 +747,13 @@ static bool __mptcp_move_skbs_from_subfl
 				mptcp_dss_corruption(msk, ssk);
 			}
 		} else {
+			sk_eat_skb(ssk, skb);
+			done = true;
+
 			if (unlikely(!fin)) {
 				DEBUG_NET_WARN_ON_ONCE(1);
 				mptcp_dss_corruption(msk, ssk);
 			}
-
-			sk_eat_skb(ssk, skb);
-			done = true;
 		}
 
 		WRITE_ONCE(tp->copied_seq, seq);
net/mptcp/protocol.h +2 -1
@@ -510,7 +510,8 @@ struct mptcp_subflow_context {
 		valid_csum_seen : 1,        /* at least one csum validated */
 		is_mptfo : 1,	    /* subflow is doing TFO */
 		close_event_done : 1,       /* has done the post-closed part */
-		__unused : 8;
+		resetting : 1,	    /* subflow is resetting */
+		__unused : 7;
 	bool	data_avail;
 	bool	scheduled;
 	bool	pm_listener;	    /* a listener managed by the kernel PM? */
net/mptcp/subflow.c +11 -0
@@ -421,6 +421,10 @@ void mptcp_subflow_reset(struct sock *ss
 	/* must hold: tcp_done() could drop last reference on parent */
 	sock_hold(sk);
 
+	subflow->resetting = 1;
+
+	/* No need to delay the actual close for to-be discarded data. */
+	__skb_queue_purge(&ssk->sk_receive_queue);
 	tcp_send_active_reset(ssk, GFP_ATOMIC);
 	tcp_done(ssk);
 	if (!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &mptcp_sk(sk)->flags))
@@ -1802,6 +1806,13 @@ static void subflow_state_change(struct
 
 	__subflow_state_change(sk);
 
+	/* Rx queue processing is unneeded, error reporting will take place at
+	 * __mptcp_close_ssk() time and subflow reset can't happen in case of
+	 * fallback: subflow_sched_work_if_closed() would be a no-op.
+	 */
+	if (subflow->resetting)
+		return;
+
 	/* as recvmsg() does not acquire the subflow socket for ssk selection
 	 * a fin packet carrying a DSS can be unnoticed if we don't trigger
 	 * the data available machinery here.

Patches currently in stable-queue which might be from [email protected] are

queue-6.6/selftests-mptcp-fix-an-uaf-in-mptcp_connect.c.patch queue-6.6/mptcp-fix-bad-accounting-in-__mptcp_subflow_push_pending.patch queue-6.6/mptcp-syncookies-remember-the-request-backup-flag.patch queue-6.6/mptcp-close-race-between-scheduler-and-state-change.patch queue-6.6/mptcp-avoid-unneeded-actions-on-subflow-reset.patch queue-6.6/mptcp-options-handle-mpc-data-csum-reqd-no-csum.patch queue-6.6/mptcp-subflow-no-need-to-copy-thmac-during-ulp_clone.patch

author maintainer
#3 lore raw

PATCH 2/3 mptcp: close race between scheduler and state change

In reply to Matthieu Baerts (NGI0)

From: Paolo Abeni <[email protected]>

commit 42064de57fb83231fcc89663a94885f228a1ee53 upstream.

The mptcp scheduler may race with subflow sockets state change: data transmission on the selected socket may fail and a later release could try to use mss_now reset to 0 for a divide operation.

Address the issue by explicitly checking for the critical scenario.

---
 net/mptcp/protocol.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/mptcp/protocol.c +3 -1
index 187e60ab3f77..3c1ad8601fb2 100644
@@ -1562,7 +1562,9 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)
 
 static void mptcp_push_release(struct sock *ssk, struct mptcp_sendmsg_info *info)
 {
-	tcp_push(ssk, 0, info->mss_now, tcp_sk(ssk)->nonagle, info->size_goal);
+	if (info->mss_now)
+		tcp_push(ssk, 0, info->mss_now, tcp_sk(ssk)->nonagle,
+			 info->size_goal);
 	release_sock(ssk);
 }
 
Signature · 1 line
2.55.0
maintainer Applied
#4 lore raw

Patch "mptcp: close race between scheduler and state change" has been added to the 6.6-stable tree

This is a note to let you know that I've just added the patch titled

mptcp: close race between scheduler and state change

to the 6.6-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
mptcp-close-race-between-scheduler-and-state-change.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From [email protected] Sat Sep 19 22:06:18 2026
From: "Matthieu Baerts (NGI0)" <[email protected]>
Date: Sat, 19 Sep 2026 22:05:57 +0200
Subject: mptcp: close race between scheduler and state change
To: [email protected], [email protected], [email protected]
Cc: Paolo Abeni <[email protected]>, [email protected], Shardul Bankar <[email protected]>, Xinyang Ge <[email protected]>, "Matthieu Baerts (NGI0)" <[email protected]>, Jakub Kicinski <[email protected]>
Message-ID: <[email protected]>

From: Paolo Abeni <[email protected]>

commit 42064de57fb83231fcc89663a94885f228a1ee53 upstream.

The mptcp scheduler may race with subflow sockets state change: data transmission on the selected socket may fail and a later release could try to use mss_now reset to 0 for a divide operation.

Address the issue by explicitly checking for the critical scenario.

---
 net/mptcp/protocol.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/mptcp/protocol.c +3 -1
@@ -1562,7 +1562,9 @@ struct sock *mptcp_subflow_get_send(stru
 
 static void mptcp_push_release(struct sock *ssk, struct mptcp_sendmsg_info *info)
 {
-	tcp_push(ssk, 0, info->mss_now, tcp_sk(ssk)->nonagle, info->size_goal);
+	if (info->mss_now)
+		tcp_push(ssk, 0, info->mss_now, tcp_sk(ssk)->nonagle,
+			 info->size_goal);
 	release_sock(ssk);
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-6.6/selftests-mptcp-fix-an-uaf-in-mptcp_connect.c.patch queue-6.6/mptcp-fix-bad-accounting-in-__mptcp_subflow_push_pending.patch queue-6.6/mptcp-syncookies-remember-the-request-backup-flag.patch queue-6.6/mptcp-close-race-between-scheduler-and-state-change.patch queue-6.6/mptcp-avoid-unneeded-actions-on-subflow-reset.patch queue-6.6/mptcp-options-handle-mpc-data-csum-reqd-no-csum.patch queue-6.6/mptcp-subflow-no-need-to-copy-thmac-during-ulp_clone.patch

author maintainer
#5 lore raw

PATCH 3/3 mptcp: fix bad accounting in __mptcp_subflow_push_pending()

In reply to Matthieu Baerts (NGI0)

From: Paolo Abeni <[email protected]>

commit f3ef03357396d4b147d8e76c75fb612c2f264ffc upstream.

If __subflow_push_pending() errors out we should avoid updating the copied byte counters, to avoid mismatch push call later on.

---
 net/mptcp/protocol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/mptcp/protocol.c +2 -1
index 3c1ad8601fb2..cd76b2d742d3 100644
@@ -1750,7 +1750,8 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk, bool
 			ret = __subflow_push_pending(sk, ssk, &info);
 			if (ret <= 0)
 				keep_pushing = false;
-			copied += ret;
+			else
+				copied += ret;
 		}
 
 		mptcp_for_each_subflow(msk, subflow) {
Signature · 1 line
2.55.0
maintainer Applied
#6 lore raw

Patch "mptcp: fix bad accounting in __mptcp_subflow_push_pending()" has been added to the 6.6-stable tree

This is a note to let you know that I've just added the patch titled

mptcp: fix bad accounting in __mptcp_subflow_push_pending()

to the 6.6-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
mptcp-fix-bad-accounting-in-__mptcp_subflow_push_pending.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From [email protected] Sat Sep 19 22:06:26 2026
From: "Matthieu Baerts (NGI0)" <[email protected]>
Date: Sat, 19 Sep 2026 22:05:58 +0200
Subject: mptcp: fix bad accounting in __mptcp_subflow_push_pending()
To: [email protected], [email protected], [email protected]
Cc: Paolo Abeni <[email protected]>, [email protected], "Matthieu Baerts (NGI0)" <[email protected]>, Jakub Kicinski <[email protected]>
Message-ID: <[email protected]>

From: Paolo Abeni <[email protected]>

commit f3ef03357396d4b147d8e76c75fb612c2f264ffc upstream.

If __subflow_push_pending() errors out we should avoid updating the copied byte counters, to avoid mismatch push call later on.

---
 net/mptcp/protocol.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/mptcp/protocol.c +2 -1
@@ -1748,7 +1748,8 @@ static void __mptcp_subflow_push_pending
 			ret = __subflow_push_pending(sk, ssk, &info);
 			if (ret <= 0)
 				keep_pushing = false;
-			copied += ret;
+			else
+				copied += ret;
 		}
 
 		mptcp_for_each_subflow(msk, subflow) {

Patches currently in stable-queue which might be from [email protected] are

queue-6.6/selftests-mptcp-fix-an-uaf-in-mptcp_connect.c.patch queue-6.6/mptcp-fix-bad-accounting-in-__mptcp_subflow_push_pending.patch queue-6.6/mptcp-syncookies-remember-the-request-backup-flag.patch queue-6.6/mptcp-close-race-between-scheduler-and-state-change.patch queue-6.6/mptcp-avoid-unneeded-actions-on-subflow-reset.patch queue-6.6/mptcp-options-handle-mpc-data-csum-reqd-no-csum.patch queue-6.6/mptcp-subflow-no-need-to-copy-thmac-during-ulp_clone.patch