From nobody Fri Sep 25 10:03:44 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 39AFF3921E7; Sat, 19 Sep 2026 19:56:55 +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=1789847818; cv=none; b=sSUG7ivz776aRi3Kw7RTc3sTlxlZu/UXNFfPaI3Rkcrc41io5Z7TByWU5+IrI5gFZbGEKU7/7X+Eu4gnFMXqwBaCRwki2lwt3PypELa20WTiy4Jc5YVmqsyjHPTSGREP5Ul9snRAWbaq+TSHQ2FPXq877UrqyY1je5b7SlQVsfA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789847818; c=relaxed/simple; bh=L/U/q3GwSp1dCDuBP16nYLIlbyjw8YUla85CzeN6vxg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NAk5PiuI1W8tpjnF8zNVaGJhOWomACH1tIJSn+L6nBcWjJKp7B4caJoEBnGpioTqWxYDIgiiR+l+4s8vrc9SdBnjYILOHhjJCXOM7WwgGtbsOtQ6uOW9CTpL8P+loagaKljY2pi/N4GxQZhfv2F0WWr/m9SL/V5r0nunlyIUJ9w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QTqTDbj5; 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="QTqTDbj5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42CBC1F00898; Sat, 19 Sep 2026 19:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789847814; bh=z98abEKY+Cl6qz8dNFUF6hxJAMW2tSEpFi/bfLMaIEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QTqTDbj5mzICk0SUn7qQREnag8svKxOJO01qaTRVCzMSGUr+A6qkq6cQw3QOHY25a +MFiFDbwXFuCTccKe+5xWCYG4eGnPnZfWdvz7yFCe0kj6Z3U6hiLVvPL7rpFtpkAbC 5RyOS/UkA654nU6efl2+S4GKooFHSnu9IvjCJaNQPOli+lYkFz4P+UanjSH93aqKPM 3lq5rFEtLqLbwrQCZglOGqCGF5mdMC8NDgsDvmqmAOnK0+kqsqQ8oRrptvqnR+Um/p bzkG5F9V0CNdX2ssa+FPBzSSpQCPqOs19m4wy0MPLD0WXRI29VdTrpMQoMD26YiGPj PVUW2fJxu7wEg== From: "Matthieu Baerts (NGI0)" To: mptcp@lists.linux.dev, stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: Gang Yan , sashal@kernel.org, "Matthieu Baerts (NGI0)" , Jakub Kicinski Subject: [PATCH 6.12.y 1/5] mptcp: annotate data-races around subflow->fully_established Date: Sat, 19 Sep 2026 21:56:44 +0200 Message-ID: <20260919195642.1977885-8-matttbe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260919195642.1977885-7-matttbe@kernel.org> References: <20260919195642.1977885-7-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=3405; i=matttbe@kernel.org; h=from:subject; bh=G9nFiKTkNU/3i3ucIlDwZs2EsvszO6Vxtaywsd+5bQM=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLWvfhjOuPrbT+pW9uU+/j/l9xYnLx0Htfk6/GcW+Wfh 5eENcvGdpSyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAExE6zrD/2SXqPTjMZaV3ySv c75+v3XCJbnajfqMpjeCzPepXTtl0Mnwz+jZv9s6rKaHf1zZ3bLCSHabPjuv2xTTKt+8C9JOfIX L+QA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Gang Yan commit 581c8cbfa934aaa555daa4e843242fcecc160f05 upstream. We introduce the same handling for potential data races with the 'fully_established' flag in subflow as previously done for msk->fully_established. Additionally, we make a crucial change: convert the subflow's 'fully_established' from 'bit_field' to 'bool' type. This is necessary because methods for avoiding data races don't work well with 'bit_field'. Specifically, the 'READ_ONCE' needs to know the size of the variable being accessed, which is not supported in 'bit_field'. Also, 'test_bit' expect the address of 'bit_field'. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/516 Signed-off-by: Gang Yan Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) Link: https://patch.msgid.link/20241021-net-next-mptcp-misc-6-13-v1-2-1ef02= 746504a@kernel.org Signed-off-by: Jakub Kicinski Stable-dep-of: 2b0f561f21b2 ("mptcp: avoid unneeded actions on subflow rese= t") Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/options.c | 4 ++-- net/mptcp/protocol.c | 2 +- net/mptcp/protocol.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index d238dd374ce9..123c3691833f 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -532,7 +532,7 @@ static bool mptcp_established_options_mp(struct sock *s= k, struct sk_buff *skb, return false; =20 /* MPC/MPJ needed only on 3rd ack packet, DATA_FIN and TCP shutdown take = precedence */ - if (subflow->fully_established || snd_data_fin_enable || + if (READ_ONCE(subflow->fully_established) || snd_data_fin_enable || subflow->snd_isn !=3D TCP_SKB_CB(skb)->seq || sk->sk_state !=3D TCP_ESTABLISHED) return false; @@ -999,7 +999,7 @@ static bool check_fully_established(struct mptcp_sock *= msk, struct sock *ssk, /* here we can process OoO, in-window pkts, only in-sequence 4th ack * will make the subflow fully established */ - if (likely(subflow->fully_established)) { + if (likely(READ_ONCE(subflow->fully_established))) { /* on passive sockets, check for 3rd ack retransmission * note that msk is always set by subflow_syn_recv_sock() * for mp_join subflows diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 2f34e92d9cce..a4054ed24605 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3685,7 +3685,7 @@ static void schedule_3rdack_retransmission(struct soc= k *ssk) struct tcp_sock *tp =3D tcp_sk(ssk); unsigned long timeout; =20 - if (mptcp_subflow_ctx(ssk)->fully_established) + if (READ_ONCE(mptcp_subflow_ctx(ssk)->fully_established)) return; =20 /* reschedule with a timeout above RTT, as we must look only for drop */ diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 2ac28f6ddff5..cd4481c93b6d 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -545,7 +545,7 @@ 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; + __unused : 9; bool data_avail; bool scheduled; bool pm_listener; /* a listener managed by the kernel PM? */ --=20 2.55.0 From nobody Fri Sep 25 10:03:44 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 5D65733122A; Sat, 19 Sep 2026 19:56:57 +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=1789847819; cv=none; b=D6hyZUmGwQN8vXhWx5RnR2MOAA4bTqK1/MzuBqyzKky0EVWrXZTvYnv53RaBHKuenEZ/b1noTg+F7Nsr9sjwNOWGoSQMYeMfZTouQwqev9lypKh+WQ+LgmSbJkQ0ZmnKleVrvT1A8ftBEQDJT/WirLpVvwYR7GWjXHeieUgloP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789847819; c=relaxed/simple; bh=pGLpKsWWZHEgJzlaDIV+DTjXeBPIzL1OgOIVS0C9GR4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rmv4f+/fJBB0C6HeDlTRTSiduaXZR/Z8m+CNKB+MkqED2UUwAXg9WcF8i+nQGHJMofM0CqEi93gcvWxrGXs15wn206IL1KIN8shk/7utyMETslNrGltxJq4UWC3krOAa+/J/HmoW9lMvDo+cMz2vt8BlSOWgCRG16KmfEN+X9x8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f6MF0qQm; 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="f6MF0qQm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2D0E1F00893; Sat, 19 Sep 2026 19:56:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789847816; bh=eE6XX+yaNM954WMOmqfQTOWWRu6GiUdVHiB01E/7LAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=f6MF0qQmwio6t7yJMpOp5rGbwUwhSP8ech1qAu3xwazEDyS7fdAvKgdDgv3krl20g BcGUiPnr/O3jtBnJbCeq0pbjt3D4O2ekONtT8Oj/iZTbp2XasvBgu5eLt+WnBCMoLl pAnSN3gixdnP4bX7H+rpXqi6J5fix7Y2kHJ4p7SSIbTU551cRy3L0QBt7ywUbYL698 eLlLrcaTzsAt7pVRVuV2oFWQPlBS394vSfpmM4y0HKZNa69ARpnHfGuAayq1tuhR/7 QxJVeWZwn8e0ebDXEVyUtD/NwxoYGy2GER0pbkMYXB9dBy1lO4IODqv4EatHvZXRNo 1fk3tZfJ5qZsg== 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 2/5] mptcp: remove unneeded READ_ONCE() annotation Date: Sat, 19 Sep 2026 21:56:45 +0200 Message-ID: <20260919195642.1977885-9-matttbe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260919195642.1977885-7-matttbe@kernel.org> References: <20260919195642.1977885-7-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=2487; i=matttbe@kernel.org; h=from:subject; bh=zFMRbwkAqOiVyRygY2AAMK/aVZaI+rC9wn7I23Kj0fU=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLWvfjrZOMkGWFhHLDkzDEH8XaNtKvfF3y+vOR6wGJ5o XCOS/tUOkpZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACYysZWRYUWm0KInvVZxjfZC u+ZuzneJumfyppT7wonbTcuDDEJ9OxgZnnmatn2++6iHNaXDhGWfVFjt7edx+7SWhx52/lu5ccc NFgA= 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 caa4a79f74f32084ce28aee8653bc04df745970d upstream. The subflow->fully_established flag is always written under the subflow socket lock. Reading such value under the same lock does not require any ONCE annotation. Fixes: 581c8cbfa934 ("mptcp: annotate data-races around subflow->fully_esta= blished") Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) Link: https://patch.msgid.link/20260908-net-mptcp-misc-fixes-7-3-rc1-v2-10-= df1de70348b6@kernel.org Signed-off-by: Jakub Kicinski Stable-dep-of: 2b0f561f21b2 ("mptcp: avoid unneeded actions on subflow rese= t") Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/options.c | 4 ++-- net/mptcp/protocol.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 123c3691833f..d238dd374ce9 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -532,7 +532,7 @@ static bool mptcp_established_options_mp(struct sock *s= k, struct sk_buff *skb, return false; =20 /* MPC/MPJ needed only on 3rd ack packet, DATA_FIN and TCP shutdown take = precedence */ - if (READ_ONCE(subflow->fully_established) || snd_data_fin_enable || + if (subflow->fully_established || snd_data_fin_enable || subflow->snd_isn !=3D TCP_SKB_CB(skb)->seq || sk->sk_state !=3D TCP_ESTABLISHED) return false; @@ -999,7 +999,7 @@ static bool check_fully_established(struct mptcp_sock *= msk, struct sock *ssk, /* here we can process OoO, in-window pkts, only in-sequence 4th ack * will make the subflow fully established */ - if (likely(READ_ONCE(subflow->fully_established))) { + if (likely(subflow->fully_established)) { /* on passive sockets, check for 3rd ack retransmission * note that msk is always set by subflow_syn_recv_sock() * for mp_join subflows diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index a4054ed24605..2f34e92d9cce 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3685,7 +3685,7 @@ static void schedule_3rdack_retransmission(struct soc= k *ssk) struct tcp_sock *tp =3D tcp_sk(ssk); unsigned long timeout; =20 - if (READ_ONCE(mptcp_subflow_ctx(ssk)->fully_established)) + if (mptcp_subflow_ctx(ssk)->fully_established) return; =20 /* reschedule with a timeout above RTT, as we must look only for drop */ --=20 2.55.0 From nobody Fri Sep 25 10:03:44 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 BBA5C3911C5; Sat, 19 Sep 2026 19:56:59 +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=1789847822; cv=none; b=ZjgRPxb0M1Ngf4BMoCG2Gbo7xXPOrSK1jEt5p2W88+tMlRQI4nOsagMfpKcbAMQlm/TaSEMMogCDEMYXi/xSigHC8TowBxYbg0moBbcyRSHoXE5zRKohBEaSJdpE8wvXlF7fEji7ipxqhUWJ0IG/wtv68UL9JuvWeXlRpoRoKTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789847822; c=relaxed/simple; bh=Z55UInsA9wBgIgUaUHSle2M3efRAUI0Iq5LQuQxaxJ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hECplsq7ZdNuYtWv1v7gDqJvT/IbUu1LRKFd1wzJFbUkina9b+5Ao/NeoMo0IcBZuXh+khI0oDR/l/8SU4lwDyRIs58ZKyJhvp3IaQe9G2rG306pmX5KRHbfQszfysFG1kYnsMkXnvKyLIXKIoSL5SMGQY4Z91GxHsJEY8RlgJg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RPR5yGHt; 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="RPR5yGHt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF13A1F000FF; Sat, 19 Sep 2026 19:56:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789847818; bh=G4asTY2bz9YuGQ/Tr+BhqtmrZnu2HsW6AXTOMK6CM/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RPR5yGHtQE+OqIyynimvOUqAax3+soIBhFdBsiGYSCavv/g+c/A4Jn+D4wav/fjGv GP55SAqthuSZZJHiZ6lcZhLdbG8ZiXgQ89qK05RyDi3zKgUOD8pirGAdES4KDPxNxp ycvY+eyIB3YfisZIb5QjafVx5ScAhu1UbCwo/kzt9sIdyezrf7bdTT4SErCksGcD9U UIKYm4WobDxVe1Kscl/1mxTUw/HmzIIeagaaV8kPft2OKkImE1jBZwf/VrqOCxcyYD qk0EnJ6nAAL8b/pyspnSbm0gpw1/OuZTkBJfcRrh6/s0G+cPQrI2AcdkViRZjusnzF Fo039V5nyHxOg== 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 3/5] mptcp: avoid unneeded actions on subflow reset Date: Sat, 19 Sep 2026 21:56:46 +0200 Message-ID: <20260919195642.1977885-10-matttbe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260919195642.1977885-7-matttbe@kernel.org> References: <20260919195642.1977885-7-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=4091; i=matttbe@kernel.org; h=from:subject; bh=NR346V9KsBhZ28IqdKdMt1XBY5IbXskqCHZmpmePxLA=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLWvfi3m/3tbveoWKH5p4694nbNy678H2Dxz9/E/Mc+q Wta2S/3dpSyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAEzkAwfD/7qFwWsLlp7hLVn7 bLtIghX3SX/3Toctah9yG/7sP5uuW8/IcP/LPZ81Jn1tPtNFX/rPzWjeKL318JxaNSlD1Z8hazw XMwAA 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. ] 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 cd4481c93b6d..436d3c92ec4a 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 : 9; + resetting : 1, /* subflow is resetting */ + __unused : 8; 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:44 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 998A332D0E3; Sat, 19 Sep 2026 19:57:00 +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=1789847823; cv=none; b=Krq4ca5+cDk7hFzcxz8PDwbNrWpbFfROkAWqY3jKrEbgmceh3mnjKaWB9ikEmgrP5hSXlUzw2qpw3+XwqHQhoAK4TcfFxasojvq9di7OjFYtPL3EvHFSK5a9UBbgAmOV1b+FAh/0r5fwE72TuDwod6AdkmGrP4oAX3LODsn7mbw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789847823; c=relaxed/simple; bh=bmSjrip0R4ION0z730h6r/gyHATsSsgEJh+I6M7HJa8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=St0EWfqfWWBU7oPUn4sd4XL7EWV68IDT01GsdBLt0zpkcAzJAF2jmzLhTH6RzMYwM3SkVV6wX8tp+Pv38pSi8uSnlcSSPXDbrIvsF7BNsAuPtInJ4sjux/j3fLgWzkfobPdWs7Nf4q6KU0wzeDEtvoBdEw2hgTUVzb+3wdmZ/DA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=l1sUDcyc; 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="l1sUDcyc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FCAB1F00899; Sat, 19 Sep 2026 19:56:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789847820; bh=SGQhVy/Ix1KWEg13IImx3L2eVLgqfe07umBSMIVihfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=l1sUDcyc33VJ2pKfNFvoo1wQ2TeV2m2yTClWbda47f7Bl/iiXjQqageGbTu597AmW HT0mEgWNbqRavJ0DP4gAuZDZx7SdKBRnCNp+0ABAMQCMG3k1mOQ3QfWjixVOU5KxH6 ZSgFJ8Lr3y9ElJAkEd4J7dFjB8VSoZor3xGIVvk/zafGy9ECOaRbhCi///WHe88pjd 7CcVtkoiGOyI+T20LVDW9mSWXwi2rHlPVdBrtWT/ET8ZbK/HP0Efpkn4tobrwPiKGZ XLtAfejEVWCYYwfoZUecnOB4Y/8qjyyMMaIGjO5whTKJW9sUMDzzR7I4dYubL4zJTw 71asaMXWAZcSQ== 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 4/5] mptcp: close race between scheduler and state change Date: Sat, 19 Sep 2026 21:56:47 +0200 Message-ID: <20260919195642.1977885-11-matttbe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260919195642.1977885-7-matttbe@kernel.org> References: <20260919195642.1977885-7-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/Th0Gd3rumMp9WSGLLWvfhfrPWxL2XL4Sdy3FNbnO7m+85U8K3xDZU8NYmpp nt9COexjlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgImYcjIyXFj66E47/8md2VGz FETs728qvDV7/Q5uG4YnXCtE9wTKJTAyPEhniw/RafyemX2jw2iOhMOy4PL/ckoZ618pNLK8uSL ICQA= 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:44 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 3087B3921E7; Sat, 19 Sep 2026 19:57:02 +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=1789847825; cv=none; b=pirNLzmEvHY2QThYPFl44DD2E6x1stbdLPuYepfrO6bYdqzR85f9SgyaXAecnH2CJOzCt5DOy+yH1FYvJVJNSbiT9ZpcDVzVX8RvQsuzBGJTCWzBtutF2pO2gZZsGAPEGChQJkqDPNkWV1aUxU814GM+mgPW5/oyxFjSC/0lCRA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789847825; c=relaxed/simple; bh=z3eG0hDjQKm0uthwOF6gQpzQRPUyT+NQRh+DalhKjps=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jnNE6d08Ck9bloImxSoDU8mAdOmlEMYMORe6qNEoQ0LCsn6d6U4Pgz1GjwWaSOefSFOvEgkwET2K7Q60FU9OnwydUNfxSGe2I3C/nI1JrRb02KMyTgAUUFgDpPcbljlMYRnG//aZneeYg5TvXPWWsBN3bPOJF8QNGUFXiL6WVx4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OCjqwO8U; 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="OCjqwO8U" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94EB11F00893; Sat, 19 Sep 2026 19:57:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789847821; bh=JUx6utZXkDZLh4llFLFuj2gS6/ubIv+qwUeW0tnZEHA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OCjqwO8Uh0B/uRE7Y05hbqhO5FFfbmAO0vxB83eG35CKm5MD4TJ+MOjVs58PYXwt9 nOJrZKANa9/aox199jrcAvCA/mPhfJNjcNOxp4iibjfsSqKXoAF+yxdKPF2+X1wWwg 2UNA4lPP4pEA9n6mGBoG5paFpKH+tBnpVhxKw6Ci/U+iUtGdAxrlfwaOWuPRzsfmwC Nx5iy+n+enXpuiwFK3dAFORC3CT7fW9tcEiE9F9d72vvrHLPsgLVMDB1pUOatMdbT2 dbUQ6Aa+vHtQFQIJFd5FQTc8SlRbLkm4iaSEvy2yD/fL0mUt9r8oReC/jVSFdvN1/Q gUq9ZOITx3Z5Q== 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 5/5] mptcp: fix bad accounting in __mptcp_subflow_push_pending() Date: Sat, 19 Sep 2026 21:56:48 +0200 Message-ID: <20260919195642.1977885-12-matttbe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260919195642.1977885-7-matttbe@kernel.org> References: <20260919195642.1977885-7-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/Th0Gd3rumMp9WSGLLWvfjfmC3/QHGTT56Hohvz3Jx8zeu8G0yf//WUjE3mb 3h8JUKwo5SFQYyLQVZMkUW6LTJ/5vMq3hIvPwuYOaxMIEMYuDgFYCKHRRj+ZxT6lsr77b80v2my Bv87gZsOD/pabSa57vzhL+tjGPvWjuGv0Ion+103rdilOM9g3g7d6Y8WF34qmv609ZrlviX7+dM PcAEA 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