From nobody Wed Dec 4 19:00:44 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DD9AE3224; Sun, 8 Sep 2024 13:06:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725800807; cv=none; b=HdfrITSWoMuFjLwMEJDRNmZK5JRLKGHi1kFW2kEg8PSRVVaP0lR2vGtOIU6f0mcpAEsecnW9HX+bYdjlbtRlGtn/GCEt15ybpAaiYaxWsjTgcVm9klWCmcTDWyysm5qBo/njbfbDo5th8eRpJkgqlOe2yfqlOKKH//ypP1SFLVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725800807; c=relaxed/simple; bh=F6/o1wQPFXzGZK3/iIpiY+bE5dbP0vR2zDwn8nk/2OM=; h=Subject:To:Cc:From:Date:In-Reply-To:Message-ID:MIME-Version: Content-Type; b=RA8iaeQxfzhkdiGtNV41VjXoLzKEfO5uwkwjYr1pSKLL0F/arQwq4rFxLFZ+nFpsoZ+PABJxJSDNh504QiHd4+rJqDCF7aNRJNxEuDq+WZqXGwgdwPpvuMW/wvmJvKNomKHHoj8sikFZHFpNIc2I47ZhmDW+K6++Y+Ult3hMXUc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=P2QO+vJa; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="P2QO+vJa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17B70C4CEC3; Sun, 8 Sep 2024 13:06:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725800806; bh=F6/o1wQPFXzGZK3/iIpiY+bE5dbP0vR2zDwn8nk/2OM=; h=Subject:To:Cc:From:Date:In-Reply-To:From; b=P2QO+vJarU8c0mGN1Kfh/dlNDyAXilTPuMqiSFtEUJneHLiTC429XMqxymbvQ1cDb 9ajJqXJYbZYkBhx9RbfqrIrB+o5pFw9YlqV6rpmIeMkRaC9iPWi0cV5HmcXeKDi5A/ OA1PiHeEH4gDOYexoCrqro3BNLGohPXJgpFvef/g= Subject: Patch "mptcp: close subflow when receiving TCP+FIN" has been added to the 5.15-stable tree To: gregkh@linuxfoundation.org,kuba@kernel.org,martineau@kernel.org,matttbe@kernel.org,mptcp@lists.linux.dev Cc: From: Date: Sun, 08 Sep 2024 15:06:41 +0200 In-Reply-To: <20240906083520.1773331-2-matttbe@kernel.org> Message-ID: <2024090840-musty-equal-02d2@gregkh> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-stable: commit X-Patchwork-Hint: ignore Content-Type: text/plain; charset="utf-8" This is a note to let you know that I've just added the patch titled mptcp: close subflow when receiving TCP+FIN to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=3Dlinux/kernel/git/stable/stable-queue.git= ;a=3Dsummary The filename of the patch is: mptcp-close-subflow-when-receiving-tcp-fin.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. From matttbe@kernel.org Fri Sep 6 10:35:29 2024 From: "Matthieu Baerts (NGI0)" Date: Fri, 6 Sep 2024 10:35:21 +0200 Subject: mptcp: close subflow when receiving TCP+FIN To: stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: MPTCP Upstream , "Matthieu Baerts (NGI0)" , Mat Martineau , Jakub Kicinski Message-ID: <20240906083520.1773331-2-matttbe@kernel.org> From: "Matthieu Baerts (NGI0)" commit f09b0ad55a1196f5891663f8888463c0541059cb upstream. When a peer decides to close one subflow in the middle of a connection having multiple subflows, the receiver of the first FIN should accept that, and close the subflow on its side as well. If not, the subflow will stay half closed, and would even continue to be used until the end of the MPTCP connection or a reset from the network. The issue has not been seen before, probably because the in-kernel path-manager always sends a RM_ADDR before closing the subflow. Upon the reception of this RM_ADDR, the other peer will initiate the closure on its side as well. On the other hand, if the RM_ADDR is lost, or if the path-manager of the other peer only closes the subflow without sending a RM_ADDR, the subflow would switch to TCP_CLOSE_WAIT, but that's it, leaving the subflow half-closed. So now, when the subflow switches to the TCP_CLOSE_WAIT state, and if the MPTCP connection has not been closed before with a DATA_FIN, the kernel owning the subflow schedules its worker to initiate the closure on its side as well. This issue can be easily reproduced with packetdrill, as visible in [1], by creating an additional subflow, injecting a FIN+ACK before sending the DATA_FIN, and expecting a FIN+ACK in return. Fixes: 40947e13997a ("mptcp: schedule worker when subflow is closed") Cc: stable@vger.kernel.org Link: https://github.com/multipath-tcp/packetdrill/pull/154 [1] Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) Link: https://patch.msgid.link/20240826-net-mptcp-close-extra-sf-fin-v1-1-9= 05199fe1172@kernel.org Signed-off-by: Jakub Kicinski [ No conflicts but 'sk' is not available in __mptcp_close_subflow in this version. It would require b6985b9b8295 ("mptcp: use the workqueue to destroy unaccepted sockets") which has not been backported to this version. It is easier to get 'sk' by casting 'msk' into a 'struct sock'. ] Signed-off-by: Matthieu Baerts (NGI0) Signed-off-by: Greg Kroah-Hartman --- net/mptcp/protocol.c | 5 ++++- net/mptcp/subflow.c | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2361,8 +2361,11 @@ static void __mptcp_close_subflow(struct =20 list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) { struct sock *ssk =3D mptcp_subflow_tcp_sock(subflow); + int ssk_state =3D inet_sk_state_load(ssk); =20 - if (inet_sk_state_load(ssk) !=3D TCP_CLOSE) + if (ssk_state !=3D TCP_CLOSE && + (ssk_state !=3D TCP_CLOSE_WAIT || + inet_sk_state_load((struct sock *)ssk) !=3D TCP_ESTABLISHED)) continue; =20 /* 'subflow_data_ready' will re-sched once rx queue is empty */ --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -1131,12 +1131,16 @@ out: /* sched mptcp worker to remove the subflow if no more data is pending */ static void subflow_sched_work_if_closed(struct mptcp_sock *msk, struct so= ck *ssk) { - if (likely(ssk->sk_state !=3D TCP_CLOSE)) + struct sock *sk =3D (struct sock *)msk; + + if (likely(ssk->sk_state !=3D TCP_CLOSE && + (ssk->sk_state !=3D TCP_CLOSE_WAIT || + inet_sk_state_load(sk) !=3D TCP_ESTABLISHED))) return; =20 if (skb_queue_empty(&ssk->sk_receive_queue) && !test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags)) - mptcp_schedule_work((struct sock *)msk); + mptcp_schedule_work(sk); } =20 static bool subflow_can_fallback(struct mptcp_subflow_context *subflow) Patches currently in stable-queue which might be from matttbe@kernel.org are queue-5.15/mptcp-pm-avoid-possible-uaf-when-selecting-endp.patch queue-5.15/mptcp-pm-only-decrement-add_addr_accepted-for-mpj-req.patch queue-5.15/mptcp-pm-fullmesh-select-the-right-id-later.patch queue-5.15/mptcp-pm-skip-connecting-to-already-established-sf.patch queue-5.15/mptcp-pm-re-using-id-of-unused-flushed-subflows.patch queue-5.15/mptcp-pm-add_addr-0-is-not-a-new-address.patch queue-5.15/mptcp-constify-a-bunch-of-of-helpers.patch queue-5.15/mptcp-pm-do-not-remove-already-closed-subflows.patch queue-5.15/mptcp-pr_debug-add-missing-n-at-the-end.patch queue-5.15/mptcp-pm-check-add_addr_accept_max-before-accepting-new-add_addr= .patch queue-5.15/mptcp-close-subflow-when-receiving-tcp-fin.patch queue-5.15/mptcp-avoid-duplicated-sub_closed-events.patch queue-5.15/mptcp-pm-send-ack-on-an-active-subflow.patch