This is a note to let you know that I've just added the patch titled mptcp: fix active subflow finalization to the 6.3-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-active-subflow-finalization.patch and it can be found in the queue-6.3 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 55b47ca7d80814ceb63d64e032e96cd6777811e5 Mon Sep 17 00:00:00 2001 From: Paolo Abeni <pabeni@xxxxxxxxxx> Date: Wed, 31 May 2023 12:37:08 -0700 Subject: mptcp: fix active subflow finalization From: Paolo Abeni <pabeni@xxxxxxxxxx> commit 55b47ca7d80814ceb63d64e032e96cd6777811e5 upstream. Active subflow are inserted into the connection list at creation time. When the MPJ handshake completes successfully, a new subflow creation netlink event is generated correctly, but the current code wrongly avoid initializing a couple of subflow data. The above will cause misbehavior on a few exceptional events: unneeded mptcp-level retransmission on msk-level sequence wrap-around and infinite mapping fallback even when a MPJ socket is present. Address the issue factoring out the needed initialization in a new helper and invoking the latter from __mptcp_finish_join() time for passive subflow and from mptcp_finish_join() for active ones. Fixes: 0530020a7c8f ("mptcp: track and update contiguous data status") Cc: stable@xxxxxxxxxxxxxxx Reviewed-by: Mat Martineau <martineau@xxxxxxxxxx> Signed-off-by: Paolo Abeni <pabeni@xxxxxxxxxx> Signed-off-by: Mat Martineau <martineau@xxxxxxxxxx> Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- net/mptcp/protocol.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -812,6 +812,13 @@ void mptcp_data_ready(struct sock *sk, s mptcp_data_unlock(sk); } +static void mptcp_subflow_joined(struct mptcp_sock *msk, struct sock *ssk) +{ + mptcp_subflow_ctx(ssk)->map_seq = READ_ONCE(msk->ack_seq); + WRITE_ONCE(msk->allow_infinite_fallback, false); + mptcp_event(MPTCP_EVENT_SUB_ESTABLISHED, msk, ssk, GFP_ATOMIC); +} + static bool __mptcp_finish_join(struct mptcp_sock *msk, struct sock *ssk) { struct sock *sk = (struct sock *)msk; @@ -826,6 +833,7 @@ static bool __mptcp_finish_join(struct m mptcp_sock_graft(ssk, sk->sk_socket); mptcp_sockopt_sync_locked(msk, ssk); + mptcp_subflow_joined(msk, ssk); return true; } @@ -3457,14 +3465,16 @@ bool mptcp_finish_join(struct sock *ssk) return false; } - if (!list_empty(&subflow->node)) - goto out; + /* active subflow, already present inside the conn_list */ + if (!list_empty(&subflow->node)) { + mptcp_subflow_joined(msk, ssk); + return true; + } if (!mptcp_pm_allow_new_subflow(msk)) goto err_prohibited; - /* active connections are already on conn_list. - * If we can't acquire msk socket lock here, let the release callback + /* If we can't acquire msk socket lock here, let the release callback * handle it */ mptcp_data_lock(parent); @@ -3487,11 +3497,6 @@ err_prohibited: return false; } - subflow->map_seq = READ_ONCE(msk->ack_seq); - WRITE_ONCE(msk->allow_infinite_fallback, false); - -out: - mptcp_event(MPTCP_EVENT_SUB_ESTABLISHED, msk, ssk, GFP_ATOMIC); return true; } Patches currently in stable-queue which might be from pabeni@xxxxxxxxxx are queue-6.3/net-dsa-mv88e6xxx-increase-wait-after-reset-deactiva.patch queue-6.3/net-smc-don-t-use-rmbs-not-mapped-to-new-link-in-smc.patch queue-6.3/net-smc-scan-from-current-rmb-list-when-no-position-.patch queue-6.3/udp6-fix-race-condition-in-udp6_sendmsg-connect.patch queue-6.3/selftests-mptcp-connect-skip-if-mptcp-is-not-supported.patch queue-6.3/mptcp-add-annotations-around-msk-subflow-accesses.patch queue-6.3/selftests-mptcp-sockopt-skip-if-mptcp-is-not-supported.patch queue-6.3/mptcp-fix-data-race-around-msk-first-access.patch queue-6.3/net-ipa-use-correct-value-for-ipa_status_size.patch queue-6.3/mptcp-avoid-unneeded-__mptcp_nmpc_socket-usage.patch queue-6.3/selftests-mptcp-simult-flows-skip-if-mptcp-is-not-supported.patch queue-6.3/selftests-mptcp-join-skip-if-mptcp-is-not-supported.patch queue-6.3/selftests-mptcp-pm-nl-skip-if-mptcp-is-not-supported.patch queue-6.3/tcp-deny-tcp_disconnect-when-threads-are-waiting.patch queue-6.3/selftests-mptcp-join-avoid-using-cmp-bytes.patch queue-6.3/selftests-mptcp-userspace-pm-skip-if-mptcp-is-not-supported.patch queue-6.3/rxrpc-truncate-uts_release-for-rxrpc-version.patch queue-6.3/net-sched-flower-fix-possible-oob-write-in-fl_set_ge.patch queue-6.3/mptcp-consolidate-passive-msk-socket-initialization.patch queue-6.3/mptcp-fix-active-subflow-finalization.patch queue-6.3/mptcp-avoid-unneeded-address-copy.patch queue-6.3/mptcp-simplify-subflow_syn_recv_sock.patch queue-6.3/mptcp-add-annotations-around-sk-sk_shutdown-accesses.patch queue-6.3/mptcp-fix-connect-timeout-handling.patch queue-6.3/selftests-mptcp-diag-skip-if-mptcp-is-not-supported.patch queue-6.3/tcp-fix-mishandling-when-the-sack-compression-is-def.patch