From nobody Fri Apr 26 04:57:21 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 345546AB6 for ; Thu, 12 Jan 2023 12:56:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37400C433D2; Thu, 12 Jan 2023 12:56:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673528179; bh=ld7VvmRk0F9VPqaIu6GsYclUHHm94aOTTXN07HbZWjQ=; h=Subject:To:Cc:From:Date:In-Reply-To:From; b=oHDD29DFEzBp1t7up4bZY/u5BGT60Tqrhh5YDYJh2u/ijQnmeqvOkULlYsP7YE8it C5BNiYj+p2+5aVe9kYj4vBBXcNcRKrm6hPeD/hmjCtRa4tSrnIc1ejkv5inPF8DnZi gW2IthmQ4WsGSjE5UolbYidP1+93OLMyw4pzVK/g= Subject: Patch "mptcp: dedicated request sock for subflow in v6" has been added to the 5.10-stable tree To: gregkh@linuxfoundation.org,kuba@kernel.org,mathew.j.martineau@linux.intel.com,matthieu.baerts@tessares.net,mptcp@lists.linux.dev,pabeni@redhat.com Cc: From: Date: Thu, 12 Jan 2023 13:56:10 +0100 In-Reply-To: <20230107014631.449550-4-mathew.j.martineau@linux.intel.com> Message-ID: <1673528170713@kroah.com> 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: dedicated request sock for subflow in v6 to the 5.10-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-dedicated-request-sock-for-subflow-in-v6.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. From stable-owner@vger.kernel.org Sat Jan 7 02:46:49 2023 From: Mat Martineau Date: Fri, 6 Jan 2023 17:46:30 -0800 Subject: mptcp: dedicated request sock for subflow in v6 To: stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: Matthieu Baerts , pabeni@redhat.com, mptc= p@lists.linux.dev, Mat Martineau , Jaku= b Kicinski Message-ID: <20230107014631.449550-4-mathew.j.martineau@linux.intel.com> From: Mat Martineau From: Matthieu Baerts commit 34b21d1ddc8ace77a8fa35c1b1e06377209e0dae upstream. tcp_request_sock_ops structure is specific to IPv4. It should then not be used with MPTCP subflows on top of IPv6. For example, it contains the 'family' field, initialised to AF_INET. This 'family' field is used by TCP FastOpen code to generate the cookie but also by TCP Metrics, SELinux and SYN Cookies. Using the wrong family will not lead to crashes but displaying/using/checking wrong things. Note that 'send_reset' callback from request_sock_ops structure is used in some error paths. It is then also important to use the correct one for IPv4 or IPv6. The slab name can also be different in IPv4 and IPv6, it will be used when printing some log messages. The slab pointer will anyway be the same because the object size is the same for both v4 and v6. A BUILD_BUG_ON() has also been added to make sure this size is the same. Fixes: cec37a6e41aa ("mptcp: Handle MP_CAPABLE options for outgoing connect= ions") Reviewed-by: Mat Martineau Cc: stable@vger.kernel.org # 5.10 Signed-off-by: Matthieu Baerts Signed-off-by: Mat Martineau Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/mptcp/subflow.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -359,7 +359,7 @@ do_reset: mptcp_subflow_reset(sk); } =20 -static struct request_sock_ops mptcp_subflow_request_sock_ops __ro_after_i= nit; +static struct request_sock_ops mptcp_subflow_v4_request_sock_ops __ro_afte= r_init; static struct tcp_request_sock_ops subflow_request_sock_ipv4_ops __ro_afte= r_init; =20 static int subflow_v4_conn_request(struct sock *sk, struct sk_buff *skb) @@ -372,7 +372,7 @@ static int subflow_v4_conn_request(struc if (skb_rtable(skb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) goto drop; =20 - return tcp_conn_request(&mptcp_subflow_request_sock_ops, + return tcp_conn_request(&mptcp_subflow_v4_request_sock_ops, &subflow_request_sock_ipv4_ops, sk, skb); drop: @@ -381,6 +381,7 @@ drop: } =20 #if IS_ENABLED(CONFIG_MPTCP_IPV6) +static struct request_sock_ops mptcp_subflow_v6_request_sock_ops __ro_afte= r_init; static struct tcp_request_sock_ops subflow_request_sock_ipv6_ops __ro_afte= r_init; static struct inet_connection_sock_af_ops subflow_v6_specific __ro_after_i= nit; static struct inet_connection_sock_af_ops subflow_v6m_specific __ro_after_= init; @@ -402,7 +403,7 @@ static int subflow_v6_conn_request(struc return 0; } =20 - return tcp_conn_request(&mptcp_subflow_request_sock_ops, + return tcp_conn_request(&mptcp_subflow_v6_request_sock_ops, &subflow_request_sock_ipv6_ops, sk, skb); =20 drop: @@ -415,7 +416,12 @@ struct request_sock *mptcp_subflow_reqsk struct sock *sk_listener, bool attach_listener) { - ops =3D &mptcp_subflow_request_sock_ops; + if (ops->family =3D=3D AF_INET) + ops =3D &mptcp_subflow_v4_request_sock_ops; +#if IS_ENABLED(CONFIG_MPTCP_IPV6) + else if (ops->family =3D=3D AF_INET6) + ops =3D &mptcp_subflow_v6_request_sock_ops; +#endif =20 return inet_reqsk_alloc(ops, sk_listener, attach_listener); } @@ -1386,7 +1392,6 @@ static struct tcp_ulp_ops subflow_ulp_op static int subflow_ops_init(struct request_sock_ops *subflow_ops) { subflow_ops->obj_size =3D sizeof(struct mptcp_subflow_request_sock); - subflow_ops->slab_name =3D "request_sock_subflow"; =20 subflow_ops->slab =3D kmem_cache_create(subflow_ops->slab_name, subflow_ops->obj_size, 0, @@ -1403,9 +1408,10 @@ static int subflow_ops_init(struct reque =20 void __init mptcp_subflow_init(void) { - mptcp_subflow_request_sock_ops =3D tcp_request_sock_ops; - if (subflow_ops_init(&mptcp_subflow_request_sock_ops) !=3D 0) - panic("MPTCP: failed to init subflow request sock ops\n"); + mptcp_subflow_v4_request_sock_ops =3D tcp_request_sock_ops; + mptcp_subflow_v4_request_sock_ops.slab_name =3D "request_sock_subflow_v4"; + if (subflow_ops_init(&mptcp_subflow_v4_request_sock_ops) !=3D 0) + panic("MPTCP: failed to init subflow v4 request sock ops\n"); =20 subflow_request_sock_ipv4_ops =3D tcp_request_sock_ipv4_ops; subflow_request_sock_ipv4_ops.init_req =3D subflow_v4_init_req; @@ -1416,6 +1422,18 @@ void __init mptcp_subflow_init(void) subflow_specific.sk_rx_dst_set =3D subflow_finish_connect; =20 #if IS_ENABLED(CONFIG_MPTCP_IPV6) + /* In struct mptcp_subflow_request_sock, we assume the TCP request sock + * structures for v4 and v6 have the same size. It should not changed in + * the future but better to make sure to be warned if it is no longer + * the case. + */ + BUILD_BUG_ON(sizeof(struct tcp_request_sock) !=3D sizeof(struct tcp6_requ= est_sock)); + + mptcp_subflow_v6_request_sock_ops =3D tcp6_request_sock_ops; + mptcp_subflow_v6_request_sock_ops.slab_name =3D "request_sock_subflow_v6"; + if (subflow_ops_init(&mptcp_subflow_v6_request_sock_ops) !=3D 0) + panic("MPTCP: failed to init subflow v6 request sock ops\n"); + subflow_request_sock_ipv6_ops =3D tcp_request_sock_ipv6_ops; subflow_request_sock_ipv6_ops.init_req =3D subflow_v6_init_req; =20 Patches currently in stable-queue which might be from stable-owner@vger.ker= nel.org are queue-5.10/mptcp-use-proper-req-destructor-for-ipv6.patch queue-5.10/mptcp-remove-mptcp-ifdef-in-tcp-syn-cookies.patch queue-5.10/mptcp-dedicated-request-sock-for-subflow-in-v6.patch queue-5.10/mptcp-mark-ops-structures-as-ro_after_init.patch