FAILED: patch "[PATCH] mptcp: decrement subflows counter on failed passive join" failed to apply to 5.15-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x f3ca0ee2cc308e33896536789cbc5f3a12ca7b30
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026072945-judge-corset-9953@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From f3ca0ee2cc308e33896536789cbc5f3a12ca7b30 Mon Sep 17 00:00:00 2001
From: Chenguang Zhao <[email protected]>
Date: Wed, 22 Jul 2026 00:14:38 +0200
Subject: [PATCH] mptcp: decrement subflows counter on failed passive join
mptcp_pm_allow_new_subflow() increments extra_subflows before __mptcp_finish_join() on the passive MP_JOIN path.
In case of race conditions, the subflow is dropped without calling mptcp_close_ssk(), so the counter is not rolled back.
Call mptcp_pm_close_subflow() when the join completion fails to decrement the subflows counter.
net/mptcp/protocol.c +1 -0
@@ -3907,6 +3907,7 @@ bool mptcp_finish_join(struct sock *ssk)mptcp_data_unlock (parent);if (!ret) { +mptcp_pm_close_subflow (msk); err_prohibited: subflow->reset_reason =MPTCP_RST_EPROHIBIT ;return false;
Sasha Levin
maintainerPATCH 1/3 mptcp: cleanup MPJ subflow list handling
From: Paolo Abeni <[email protected]>
[ Upstream commit 3e5014909b5661b3da59990d72a317a45ba3b284 ]
We can simplify the join list handling leveraging the mptcp_release_cb(): if we can acquire the msk socket lock at mptcp_finish_join time, move the new subflow directly into the conn_list, otherwise place it on join_list and let the release_cb process such list.
Since pending MPJ connection are now always processed in a timely way, we can avoid flushing the join list every time we have to process all the current subflows.
Additionally we can now use the mptcp data lock to protect the join_list, removing the additional spin lock.
Finally, the MPJ handshake is now always finalized under the msk socket lock, we can drop the additional synchronization between mptcp_finish_join() and mptcp_close().
Stable-dep-of: f3ca0ee2cc30 ("mptcp: decrement subflows counter on failed passive join")
--- net/mptcp/pm_netlink.c | 4 -- net/mptcp/protocol.c | 118 +++++++++++++++++------------------------ net/mptcp/protocol.h | 15 +----- net/mptcp/sockopt.c | 24 +++------ net/mptcp/subflow.c | 5 +- 5 files changed, 60 insertions(+), 106 deletions(-)
net/mptcp/pm_netlink.c +0 -4
@@ -174,7 +174,6 @@ select_local_address(const struct pm_nl_pernet *pernet,msk_owned_by_me (msk);rcu_read_lock (); -__mptcp_flush_join_list (msk);list_for_each_entry_rcu (entry, &pernet->local_addr_list, list) {if (!(entry->flags &MPTCP_PM_ADDR_FLAG_SUBFLOW ))continue ;
@@ -619,7 +618,6 @@ static unsigned int fill_local_addresses_vec(struct mptcp_sock *msk,mptcp_local_address ((struct sock_common *)msk, &mpc_addr);rcu_read_lock (); -__mptcp_flush_join_list (msk);list_for_each_entry_rcu (entry, &pernet->local_addr_list, list) {if (!(entry->flags &MPTCP_PM_ADDR_FLAG_FULLMESH ))continue ;
@@ -658,7 +656,6 @@ static unsigned int fill_local_addresses_vec(struct mptcp_sock *msk,unsigned int local_addr_max =mptcp_pm_get_local_addr_max (msk);rcu_read_lock (); -__mptcp_flush_join_list (msk);list_for_each_entry_rcu (entry, &pernet->local_addr_list, list) {if (!(entry->flags &MPTCP_PM_ADDR_FLAG_SUBFLOW ))continue ;
@@ -796,7 +793,6 @@ void mptcp_pm_nl_addr_send_ack_avoid_list(struct mptcp_sock *msk, !mptcp_pm_should_rm_signal(msk))return ; -__mptcp_flush_join_list (msk);mptcp_for_each_subflow (msk, subflow) {if (!__mptcp_subflow_active (subflow))continue ;
net/mptcp/protocol.c +50 -68
217 lines not on this page · raw message
net/mptcp/protocol.h +2 -13
@@ -121,7 +121,7 @@#define MPTCP_CLEAN_UNA 7#define MPTCP_ERROR_REPORT 8#define MPTCP_RETRANSMIT 9 -#define MPTCP_WORK_SYNC_SETSOCKOPT 10 +#define MPTCP_FLUSH_JOIN_LIST 10#define MPTCP_CONNECTED 11static inline bool before64 (__u64 seq1,__u64 seq2)
@@ -252,7 +252,6 @@ struct mptcp_sock {bool use_64bit_ack;/* Set when we received a 64-bit DSN */ bool csum_enabled;bool allow_infinite_fallback; -spinlock_t join_list_lock;int keepalive_cnt;int keepalive_idle;int keepalive_intvl;
@@ -508,15 +507,6 @@ mptcp_subflow_get_mapped_dsn(const struct mptcp_subflow_context *subflow)return subflow->map_seq +mptcp_subflow_get_map_offset (subflow); } -static inline void mptcp_add_pending_subflow (struct mptcp_sock *msk, -struct mptcp_subflow_context *subflow) -{ -sock_hold (mptcp_subflow_tcp_sock (subflow)); -spin_lock_bh (&msk->join_list_lock); -list_add_tail (&subflow->node, &msk->join_list); -spin_unlock_bh (&msk->join_list_lock); -} -void mptcp_subflow_process_delegated (struct sock *ssk);static inline void mptcp_subflow_delegate (struct mptcp_subflow_context *subflow,int action)
@@ -684,7 +674,6 @@ void __mptcp_data_acked(struct sock *sk);void __mptcp_error_report (struct sock *sk);void mptcp_subflow_eof (struct sock *sk);bool mptcp_update_rcv_data_fin (struct mptcp_sock *msk,u64 data_fin_seq,bool use_64bit); -void __mptcp_flush_join_list (struct mptcp_sock *msk);static inline bool mptcp_data_fin_enabled (const struct mptcp_sock *msk) { return READ_ONCE(msk->snd_data_fin_enable) &&
@@ -859,7 +848,7 @@ static inline bool mptcp_pm_add_addr_c_flag_case(struct mptcp_sock *msk) }void mptcp_sockopt_sync (struct mptcp_sock *msk,struct sock *ssk); -void mptcp_sockopt_sync_all (struct mptcp_sock *msk); +void mptcp_sockopt_sync_locked (struct mptcp_sock *msk,struct sock *ssk);static inline struct mptcp_ext *mptcp_get_ext (const struct sk_buff *skb) {
net/mptcp/sockopt.c +6 -18
@@ -904,27 +904,15 @@ void mptcp_sockopt_sync(struct mptcp_sock *msk, struct sock *ssk) } } -void mptcp_sockopt_sync_all (struct mptcp_sock *msk) +void mptcp_sockopt_sync_locked (struct mptcp_sock *msk,struct sock *ssk) { -struct mptcp_subflow_context *subflow; -struct sock *sk = (struct sock *)msk; -u32 seq; - - seq =sockopt_seq_reset (sk); +struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (ssk); -mptcp_for_each_subflow (msk, subflow) { -struct sock *ssk =mptcp_subflow_tcp_sock (subflow); -u32 sseq =READ_ONCE (subflow->setsockopt_seq); +msk_owned_by_me (msk); -if (sseq != msk->setsockopt_seq) { -__mptcp_sockopt_sync (msk, ssk); -WRITE_ONCE (subflow->setsockopt_seq, seq); - }else if (sseq != seq) { -WRITE_ONCE (subflow->setsockopt_seq, seq); - } +if (READ_ONCE (subflow->setsockopt_seq) != msk->setsockopt_seq) { +sync_socket_options (msk, ssk); -cond_resched (); + subflow->setsockopt_seq = msk->setsockopt_seq; } - - msk->setsockopt_seq = seq; }
net/mptcp/subflow.c +2 -3
@@ -1490,7 +1490,8 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc, subflow->request_bkup = !!(flags &MPTCP_PM_ADDR_FLAG_BACKUP );mptcp_info2sockaddr (remote, &addr, ssk->sk_family); -mptcp_add_pending_subflow (msk, subflow); +sock_hold (ssk); +list_add_tail (&subflow->node, &msk->conn_list);mptcp_sockopt_sync (msk, ssk); err =kernel_connect (sf, (struct sockaddr *)&addr, addrlen,O_NONBLOCK );if (err && err != -EINPROGRESS )
@@ -1503,9 +1504,7 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc,return err; failed_unlink: -spin_lock_bh (&msk->join_list_lock);list_del (&subflow->node); -spin_unlock_bh (&msk->join_list_lock);sock_put (mptcp_subflow_tcp_sock (subflow)); failed:
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/3 mptcp: fix subflow accounting on close
From: Paolo Abeni <[email protected]>
[ Upstream commit 95d686517884a403412b000361cee2b08b2ed1e6 ]
If the PM closes a fully established MPJ subflow or the subflow creation errors out in it's early stage the subflows counter is not bumped accordingly.
This change adds the missing accounting, additionally taking care of updating accordingly the 'accept_subflow' flag.
Stable-dep-of: f3ca0ee2cc30 ("mptcp: decrement subflows counter on failed passive join")
--- net/mptcp/protocol.h | 14 ++++++++++++++ net/mptcp/subflow.c | 12 +++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-)
net/mptcp/protocol.h +14 -0
@@ -839,6 +839,20 @@ unsigned int mptcp_pm_get_add_addr_accept_max(const struct mptcp_sock *msk);unsigned int mptcp_pm_get_subflows_max (const struct mptcp_sock *msk);unsigned int mptcp_pm_get_local_addr_max (const struct mptcp_sock *msk); +/* called under PM lock */ +static inline void __mptcp_pm_close_subflow (struct mptcp_sock *msk) +{ +if (--msk->pm.subflows <mptcp_pm_get_subflows_max (msk)) +WRITE_ONCE (msk->pm.accept_subflow, true); +} + +static inline void mptcp_pm_close_subflow (struct mptcp_sock *msk) +{ +spin_lock_bh (&msk->pm.lock); +__mptcp_pm_close_subflow (msk); +spin_unlock_bh (&msk->pm.lock); +} +static inline bool mptcp_pm_add_addr_c_flag_case (struct mptcp_sock *msk) { return READ_ONCE(msk->pm.remote_deny_join_id0) &&
net/mptcp/subflow.c +9 -3
@@ -1434,20 +1434,20 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc,struct sockaddr_storage addr;int remote_id = remote->id;int local_id = loc->id; +int err = -ENOTCONN ;struct socket *sf;struct sock *ssk;u32 remote_token;int addrlen;int ifindex;u8 flags; -int err;if (!mptcp_is_fully_established (sk)) -return -ENOTCONN ; + goto err_out; err =mptcp_subflow_create_socket (sk, &sf);if (err) -return err; + goto err_out; ssk = sf->sk; subflow =mptcp_subflow_ctx (ssk);
@@ -1510,6 +1510,12 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc, failed: subflow->disposable =1 ;sock_release (sf); + +err_out: +/* we account subflows before the creation, and this failures will not +* be caught by sk_state_change() +*/ +mptcp_pm_close_subflow (msk);return err; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/3 mptcp: decrement subflows counter on failed passive join
In reply to Sasha LevinFrom: Chenguang Zhao <[email protected]>
[ Upstream commit f3ca0ee2cc308e33896536789cbc5f3a12ca7b30 ]
mptcp_pm_allow_new_subflow() increments extra_subflows before __mptcp_finish_join() on the passive MP_JOIN path.
In case of race conditions, the subflow is dropped without calling mptcp_close_ssk(), so the counter is not rolled back.
Call mptcp_pm_close_subflow() when the join completion fails to decrement the subflows counter.
--- net/mptcp/protocol.c | 1 + 1 file changed, 1 insertion(+)
net/mptcp/protocol.c +1 -0
@@ -3361,6 +3361,7 @@ bool mptcp_finish_join(struct sock *ssk)mptcp_data_unlock (parent);if (!ret) { +mptcp_pm_close_subflow (msk); err_prohibited: subflow->reset_reason =MPTCP_RST_EPROHIBIT ;return false;
Signature · 1 line
2.53.0