From nobody Fri Sep 25 10:03:28 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 91A623D4118; Sun, 20 Sep 2026 09:41:49 +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=1789897310; cv=none; b=uXzrg5ga0flaeu3QuuOEf04iP58mocOvG4LSiR0uxZQwM9rw9gyO0KdvxOrw/gFRcVxnE53fBgfAAMKG1M4PfmGy6WssHd34uDopchUo37l7zSkj0sqOeUPZqTuB5UowWsALXq98b1ZJbcMPS+SB85phkuoTYTXnC3K4jojdAL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789897310; c=relaxed/simple; bh=acsD/QIOgE1y6mKe1ehqnWMshOPRKQ1kaLBIpehujC0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s6bvUkEXcqyIZ9ZGvialraRjsGzBgr7oA8xjobNmEEpQlPRoqzsY5JgGKraGl+Dv9YYgzsHxp4KgXskMg51GpeYJwmkloviWTxTK1ifWKsmDCNKz0N1qZGrF9iGc8q3g0BcNz+WYe9euPNx4bLFCiFLA66BkgifmwG4R2mlYswk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ku26sAIK; 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="Ku26sAIK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF1901F00893; Sun, 20 Sep 2026 09:41:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789897309; bh=rZGO4Hudl7eD38XFJkW/+LC0k/5Q7X2iFOQaai48hZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ku26sAIKBet1cie5AyD2sZkH7LBcSvz7USRQG/fV56/6uA1oMUCYt56yjP4qwIziD 23cskHIniXjGRztQXj3elVrR36I/H/+POy6EpZWemSLs6iy8otlnWKp3uXk2f0vXKv 9SaFzRCHajXtgg/o6FiVuq+kS+L+UL58ac0BUJaqmzvH6lVwSRRn1ailEASoD5Un4K shXt1MjF1nAE6YP+B/V6E0kOrGU1MVAculdZreHw4H1u57jlhXZXQf8GoKbMNYuZ7K H/E0+EHyBJSUFqsdXjT8x8d7o/5bkjJwyl/REwyuG4ssgb04NY4A1PgR4clxznD0Bs cnwHb5/PfYm/Q== 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 6.12.y v2 1/3] mptcp: avoid unneeded actions on subflow reset Date: Sun, 20 Sep 2026 11:41:37 +0200 Message-ID: <20260920094135.2431797-6-matttbe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260920094135.2431797-5-matttbe@kernel.org> References: <20260920094135.2431797-5-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=4238; i=matttbe@kernel.org; h=from:subject; bh=YSWphiEdLanbBPSw02GktoslVQxo813M7ClHpCGIEFg=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLWrwqMaL05/blJXlXd3LKnfm8m8ybcv14eH176bvEDt 64Ptzi7O0pZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACZy+RvD/8w2q+P8U27PLZy5 vWyBnXTsQQnGE/MrnJv7DQUsBULFlBj+mdfu+mgS+eNCqWqX2XaDi6JpfOtc52cf3P9G7vqZV3a FrAA= 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 a conflict in protocol.h, because __unused is at a different number. Decrement the one from this version and add the new flag above. ] 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 2f34e92d9cce..ff63ba5ee464 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -747,13 +747,13 @@ static bool __mptcp_move_skbs_from_subflow(struct mpt= cp_sock *msk, mptcp_dss_corruption(msk, ssk); } } else { + sk_eat_skb(ssk, skb); + done =3D true; + if (unlikely(!fin)) { DEBUG_NET_WARN_ON_ONCE(1); mptcp_dss_corruption(msk, ssk); } - - sk_eat_skb(ssk, skb); - done =3D true; } =20 WRITE_ONCE(tp->copied_seq, seq); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 2ac28f6ddff5..5fdf2b55b3cc 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -545,7 +545,8 @@ struct mptcp_subflow_context { is_mptfo : 1, /* subflow is doing TFO */ close_event_done : 1, /* has done the post-closed part */ mpc_drop : 1, /* the MPC option has been dropped in a rtx */ - __unused : 8; + resetting : 1, /* subflow is resetting */ + __unused : 7; bool data_avail; bool scheduled; bool pm_listener; /* a listener managed by the kernel PM? */ diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 267e0424eea5..cfa029b4d7f3 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -440,6 +440,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); mptcp_send_active_reset_reason(ssk); tcp_done(ssk); if (!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &mptcp_sk(sk)->flags)) @@ -1857,6 +1861,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; + /* 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. --=20 2.55.0 From nobody Fri Sep 25 10:03:28 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 A72A83ED3B4; Sun, 20 Sep 2026 09:41:51 +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=1789897313; cv=none; b=NcWE7y2u/oSHypd8OAZ9QZ+8vkVgHmXINBxnJycsQaPbiMQGcS1CFHvzDo9NEiINHR3cgkkYcox1s77wmlMh3ja686tASw2r6bsCM7fQKDrsxLuRFNNUPF/77s08WHLJTqoMeaueabRmsTOFLEOF8aW48OiaCGhB7NzJfTjUPVo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789897313; c=relaxed/simple; bh=bmSjrip0R4ION0z730h6r/gyHATsSsgEJh+I6M7HJa8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CupA+rmQFlv1EJc375yoeQZ9AnlJQ4NcZOl6BU7CCTt1l86xot9S4HpzmKM2QHBhtWXf/wG78AmAuFOMbOiCd8PZvDtjkAfs/rRzxk+Q32QtxqObzR82SXAVKGx0xPm96eanogSDBqWgSuSW4gbQ4lnBLnS9DXfQJZkBMBA1Abo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y/ZJhI4F; 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="Y/ZJhI4F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A69251F0089A; Sun, 20 Sep 2026 09:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789897311; bh=SGQhVy/Ix1KWEg13IImx3L2eVLgqfe07umBSMIVihfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Y/ZJhI4FMq3dIHA4StuOxF7Sddbnu8GxdU1Bu9l4o6tVQ8aKZVMO+wt+9Q2S0lMYX BAI4MRbUnSByMFwULgk23oIhYGzgZSZdRBO/qOMqsmLwUWC+Bag/Aubde+m1DJSoGv 1gcj4few1JWH6Pj7KSeT6JqrwPZQkhNj9JDIDV58/8q0RD/0t1fU5W6ckHVsuf5OId 7DL3PmBeYeGhwcGgs14reGQJS4kFy4SaAOJHjBRl1MI0hKyTxVog1qhJ34F+bgYtaR mAMwf01ZF/OeB07ft1YXBxkeolJ/0WeEFEzMvCziHMDg3tE5GmkKqlfTiOtAW/9f12 tIV35irFSKqPQ== 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 6.12.y v2 2/3] mptcp: close race between scheduler and state change Date: Sun, 20 Sep 2026 11:41:38 +0200 Message-ID: <20260920094135.2431797-7-matttbe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260920094135.2431797-5-matttbe@kernel.org> References: <20260920094135.2431797-5-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=1636; i=matttbe@kernel.org; h=from:subject; bh=1Uq5TXp1CKF/jKqL7YfsUTcPXXbot2SxFy+EEa/xV7U=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLWrwoq1vrYl7Ll8BM57qktTnfzfWcq+Nb4hkqemsRU0 70+hPNYRykLgxgXg6yYIot0W2T+zOdVvCVefhYwc1iZQIYwcHEKwEQWfGNkWGUSxu55Z8K2u9mB +nelH82rFczdadP9d5fKZsV+9huX9Rn+Fx/89O9ett/zxNcpqZc6pLVNXq/IqrhkWNp/3F+6uWc 7CwA= 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 ff63ba5ee464..1304f3cb6d14 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1567,7 +1567,9 @@ struct sock *mptcp_subflow_get_send(struct mptcp_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 From nobody Fri Sep 25 10:03:28 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 613123EDAB5; Sun, 20 Sep 2026 09:41:53 +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=1789897314; cv=none; b=MYhwxzyqy6IQi0yvqCKExvXWeE/8X6n2wdfPAUwiScMcHyN8TSpbTMEGrW7TZ8g5pkalkcFkIQyvXSmElfXr91VNJABVHhGWvuvKUEL05XBaPD9iU5DYCw//o0Aavwuh+eCljB7N4uONQCzvTsV76C9Vq0v19RBB+DnuCqCeal4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789897314; c=relaxed/simple; bh=z3eG0hDjQKm0uthwOF6gQpzQRPUyT+NQRh+DalhKjps=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RhiF/H7GWVTpAAp3v54DKQdHN+s7yve/xEW+Q1NMejOvVH7Fj3dzy3ajVO1+u2LFpzz+ULGR1u8oswwPyvJHHVb9HQxbPrClRbTmB3STPWMCiLoXfUVOZsfq5ubL4pKLc5pNwIec9RQ0dGn1X9K8+zX27coPArqZQxYPFlYYLyA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gBnKD3OJ; 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="gBnKD3OJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1DDF1F00899; Sun, 20 Sep 2026 09:41:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789897313; bh=JUx6utZXkDZLh4llFLFuj2gS6/ubIv+qwUeW0tnZEHA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gBnKD3OJYNuOYciJwCaZc9rUOpd4N4COYfPJE5XtUdPJ9A8diWrGV6EO8/QABhwhA bBaJigc0Wt1kByu3ZRoHcdw1i+ssNiaKA9Ce7XPWrpqdbS6LCECZwJQ8VxQt2AE90l j8gTKzAMUWnkKoWxWo9EJYKaMonQxSxW1u+Lyv75yTLvNPomzq5fJYvU8p/atRw+GR QbivPzsdw6FCwoJmnVOdkDQ3Gs5zdnAA5xZKDdaSf0jIFzvmxt9i76fzwfkVw7U9J/ s4lZYoZ3en3wpPfUnaK/SkyhePzUwvD5ZmMTTi1URUElHTW3+5WNkizoruVWzqs6ws H7omO3AIgK59g== From: "Matthieu Baerts (NGI0)" To: mptcp@lists.linux.dev, stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: Paolo Abeni , sashal@kernel.org, "Matthieu Baerts (NGI0)" , Jakub Kicinski Subject: [PATCH 6.12.y v2 3/3] mptcp: fix bad accounting in __mptcp_subflow_push_pending() Date: Sun, 20 Sep 2026 11:41:39 +0200 Message-ID: <20260920094135.2431797-8-matttbe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260920094135.2431797-5-matttbe@kernel.org> References: <20260920094135.2431797-5-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=1208; i=matttbe@kernel.org; h=from:subject; bh=D7mEQdlUlOkhHr7cnnZ0yQi/+uAedqRlpcZ5JLZDPAo=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLWrwpuzJZ/oLjJJ89D0Y15bk6+5nXeDabP/3pKxibzN zy+EiHYUcrCIMbFICumyCLdFpk/83kVb4mXnwXMHFYmkCEMXJwCMBFxMYa/0jkRM3Mf/mI61PIm OWkFs/Ne6cDQHXyNfzXzbBtTkrMmMvwzudlxprXPxsjd9WS+6KICRx/Zwy+j5/yY53JKVSDzuxQ 3AA== 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 f3ef03357396d4b147d8e76c75fb612c2f264ffc upstream. If __subflow_push_pending() errors out we should avoid updating the copied byte counters, to avoid mismatch push call later on. Fixes: 0fa1b3783a17 ("mptcp: use get_send wrapper") Cc: stable@vger.kernel.org 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-3-0= cf5c72667c8@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 1304f3cb6d14..ee160c783ff5 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1757,7 +1757,8 @@ static void __mptcp_subflow_push_pending(struct sock = *sk, struct sock *ssk, bool ret =3D __subflow_push_pending(sk, ssk, &info); if (ret <=3D 0) keep_pushing =3D false; - copied +=3D ret; + else + copied +=3D ret; } =20 mptcp_for_each_subflow(msk, subflow) { --=20 2.55.0