From nobody Fri Sep 25 10:03:26 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0BE62CCC6; Sat, 19 Sep 2026 20:29:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789849772; cv=none; b=Lex3wbRQMjZteVlTZQQOFQTrHakIZQJGSiGpGOi9lJIjv/AO/1JPV4BJ/C1Kh0vVw2a/Yf/CNyqU4FcCav5jboQ4W61covhAK82Wcbbv/jre+jJQ29Kd9fSO3P0REVN2U7Dn5DvMuJnpV9sNi+b3cgx/0c3RjCWCC/Ye0SYMNSY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789849772; c=relaxed/simple; bh=jr6JtzfJLZJ6Rcyo+JBr5e2OEnanKPEWUu2j/hh/7+c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lvknl18YLVaf+wdzG/FxL8W4tGsuydctvJqmH47T3BAwAgQn4h+0zmhr2AsKhxVp160xXB5Q7GR25Iho6W7JWQTAqHx+/O5vmf5a5rr42CCPlbnHHjaMyORFbBAhDAD+8K0se2/HJWeT47EurrYoEhH60NMwmzOLarZPMpWF1Ho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SHCuldAD; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SHCuldAD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F12E41F00899; Sat, 19 Sep 2026 20:29:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789849770; bh=OXob0CtWk1GOuG4T0K4+bZW8lSxsiKhi0tjFvkvtUlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SHCuldADl67xmuPFMFTXaYS1+wakpLWyBHvddKVZLf9V3iKdjd5TS/+DLMI76yDrm ET3NLAWiV+QTpbUpeKBpvgDn1pIhwPwN77donBF0op9kUwPlmw3DdXg/9MureESXxJ 9MMEiTZwDHG0HLtmeG2F/RloZi8GiJaVycnMtya3IKh7StGefreMoROpK0Gxz/M2m7 4rfl5zgYRYJD1+VVTmqwVNKxBKliAKqCZZhQi4T/3YGPGA5vvCcdliiWmnIZDW28PY bSrX1ZmusrfisAYV2lHsOBhfuZG7m6/KQ6JooqC+vKoMcoXl6hr6FppMEeS8Hh7iJR iYjNbnrAlffkw== From: "Matthieu Baerts (NGI0)" To: mptcp@lists.linux.dev, stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: Paolo Abeni , sashal@kernel.org, Xinyang Ge , "Matthieu Baerts (NGI0)" , Jakub Kicinski Subject: [PATCH 5.15.y 1/2] mptcp: avoid unneeded actions on subflow reset Date: Sat, 19 Sep 2026 22:29:20 +0200 Message-ID: <20260919202918.2074632-5-matttbe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260919202918.2074632-4-matttbe@kernel.org> References: <20260919202918.2074632-4-matttbe@kernel.org> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4736; i=matttbe@kernel.org; h=from:subject; bh=Q8LVpAPEcJDd+SeIXPfiNFrP8EjFcU54jFxZUfCfZe4=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLWfVhQuCXsVsrmDX4SHiqLvEteRbKsMvmkILFoRoHM3 Ck7yted6yhlYRDjYpAVU2SRbovMn/m8irfEy88CZg4rE8gQBi5OAZiIZA/DPzOlVNNE1fkvplm2 F0oe+Kwby8TxWUEmwO3WM/F5NfZzvBn+KV7tXHb+vzvzxoj3bfa1W4rnn/24f8eclj8HHv/ZxqA rzAgA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Paolo Abeni 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. Fixes: e32d262c89e2 ("mptcp: handle consistently DSS corruption") Cc: stable@vger.kernel.org Reported-by: Xinyang Ge Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) Link: https://patch.msgid.link/20260917-net-mptcp-misc-fixes-7-3-rc4-v2-1-0= cf5c72667c8@kernel.org Signed-off-by: Jakub Kicinski [ 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 =3D true" can be moved along without consequences. Also, the context is slightly different because there is no DEBUG_NET_WARN_ON_ONCE in this version, see the backport commit 12c1676d598e ("mptcp: handle consistently DSS corruption"). 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. The context is also a bit different with data_avail being an enum, but that's without consequences here. Also a conflict in subflow.c, because commit 71154bbe4942 ("mptcp: fallback earlier on simult connection") was not needed in this version, and cause conflicts in the context, but that's without consequences here. ] Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.c | 6 +++--- net/mptcp/protocol.h | 3 ++- net/mptcp/subflow.c | 11 +++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 522d8740a0f3..42190efadb11 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -687,11 +687,11 @@ static bool __mptcp_move_skbs_from_subflow(struct mpt= cp_sock *msk, if (unlikely(map_remaining < len)) mptcp_dss_corruption(msk, ssk); } else { - if (unlikely(!fin)) - mptcp_dss_corruption(msk, ssk); - sk_eat_skb(ssk, skb); done =3D true; + + if (unlikely(!fin)) + mptcp_dss_corruption(msk, ssk); } =20 WRITE_ONCE(tp->copied_seq, seq); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 609e7768fab3..913d9b1474b0 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -447,7 +447,8 @@ struct mptcp_subflow_context { stale : 1, /* unable to snd/rcv data, do not use for xmit */ valid_csum_seen : 1, /* at least one csum validated */ close_event_done : 1, /* has done the post-closed part */ - __unused : 11; + resetting : 1, /* subflow is resetting */ + __unused : 10; enum mptcp_data_avail data_avail; bool pm_listener; /* a listener managed by the kernel PM? */ u32 remote_nonce; diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 33b16ea7ae5b..5ee090b74fa4 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -373,6 +373,10 @@ void mptcp_subflow_reset(struct sock *ssk) /* must hold: tcp_done() could drop last reference on parent */ sock_hold(sk); =20 + subflow->resetting =3D 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)) @@ -1667,6 +1671,13 @@ static void subflow_state_change(struct sock *sk) =20 __subflow_state_change(sk); =20 + /* 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; + msk =3D mptcp_sk(parent); if (subflow_simultaneous_connect(sk)) { mptcp_propagate_sndbuf(parent, sk); --=20 2.55.0 From nobody Fri Sep 25 10:03:26 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC5BF2CCC6; Sat, 19 Sep 2026 20:29:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789849773; cv=none; b=cW5CXSgGIGRB6pEs+CrHtK6m5l94JraxOCncdrrJJp7zeCsjXdxIWsdqnKmIMrqoCZuzJcMdgrOsago2fC2A6ZDQ24RR7b3hiktsI6WBjag7MPtT8hm46Qar5xAY0Koa0SQDvdkUoabe6UYEPgGPiMsvc/KcR5mDAJbp3EAePwc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789849773; c=relaxed/simple; bh=wIQkGPrpNhIPeBtQ1N8sfhUKxd0h+65q0mrZReynOIY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dFj2WOR9GoIicMAeWuRl2UHrxiGiF0PfCbX9WvHhQjQRLMJldE2kr4EhasfrczzA/FstclQm5A2VqUS9xKMithElzxHcTk9tYOWjdS4JRsoS8IS02CHziH2uZOPT4BVYVyVMHwLsuXG+cWdGZQ8fo9VVdUzhmJXo0Pm4XMCKUzA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ToFvT9JD; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ToFvT9JD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2F711F000FF; Sat, 19 Sep 2026 20:29:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789849772; bh=19uWkkjWrdCxybP4+/+w8dWq8MXHmX5ZLbJ98WpydaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ToFvT9JDiSGqdaYHvWSz+AFBC0Ya8da+FxkaSQFQJnqC/pP4FpRKgtvf2hyM89k0J 1cpRBVD4NYoFMoyUb0VlAxcCCc9a/hbSfO4obAF//syU+m0hy3fE71J0sGfXMyYBb/ HY5PpX/7t+vbDZ7MSz4YkD7ZQ+bCcs8WElJKcU6kfBjaqPqizJpyzy0NaUr2WTzqwZ 59/K/NYT4K0aMq+KiQQjG0AX1lSvHu1He4Kg7vF4J2us2RShq7w7nP/cLhNjKLrJHY /wasNzjtd80ZZ+OnT5/u2UZQyyc6WDVvcCG54K76n8heTNfD7Un0JUQRC8LFxJ1v2P Tz8r1b8dpwwlQ== From: "Matthieu Baerts (NGI0)" To: mptcp@lists.linux.dev, stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: Paolo Abeni , sashal@kernel.org, Shardul Bankar , Xinyang Ge , "Matthieu Baerts (NGI0)" , Jakub Kicinski Subject: [PATCH 5.15.y 2/2] mptcp: close race between scheduler and state change Date: Sat, 19 Sep 2026 22:29:21 +0200 Message-ID: <20260919202918.2074632-6-matttbe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260919202918.2074632-4-matttbe@kernel.org> References: <20260919202918.2074632-4-matttbe@kernel.org> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1643; i=matttbe@kernel.org; h=from:subject; bh=SM1NCJ+XyNa0LwwgpdEzAq2+G78I5l0TBurls9PYHR0=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLWfVi4/FfZwye/AlR0imvYThhKad/o9va3s1rJwKNoz pv6eO6SjlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIkIeDIyHPyZ4qyzOYDho6HV /6pjK2YlLS/c5G/2jc24i70wTt0nk+GffscxkeNuz24f+3tLSWL5mnBpp9iChM53vN43kr6+/Rb DCgA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Paolo Abeni 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. Fixes: c886d70286bf ("mptcp: do not queue data on closed subflows") Cc: stable@vger.kernel.org Reported-by: Shardul Bankar Reported-by: Xinyang Ge Closes: https://lore.kernel.org/20260525194828.1137119-1-shardul.b@mpiricso= ftware.com Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) Link: https://patch.msgid.link/20260917-net-mptcp-misc-fixes-7-3-rc4-v2-2-0= cf5c72667c8@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 42190efadb11..2f18dcb8d034 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1621,7 +1621,9 @@ static struct sock *mptcp_subflow_get_send(struct mpt= cp_sock *msk) =20 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); } =20 --=20 2.55.0