All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni at redhat.com>
To: mptcp at lists.01.org
Subject: [MPTCP] [PATCH net-next 3/8] mptcp: mark as fallback even early ones
Date: Thu, 23 Jul 2020 13:02:31 +0200	[thread overview]
Message-ID: <1fa72209d016ee555828b18bc3675784d416d543.1595431326.git.pabeni@redhat.com> (raw)
In-Reply-To: cover.1595431326.git.pabeni@redhat.com

[-- Attachment #1: Type: text/plain, Size: 1771 bytes --]

In the unlikely event of a failure at connect time,
we currently clear the request_mptcp flag - so that
the MPC handshake is not started at all, but the msk
is not explicitly marked as fallback.

This would lead to later insertion of wrong DSS options
in the xmitted packets, in violation of RFC specs and
possibly fooling the peer.

Fixes: e1ff9e82e2ea ("net: mptcp: improve fallback to TCP")
Reviewed-by: Mat Martineau <mathew.j.martineau(a)linux.intel.com>
Tested-by: Christoph Paasch <cpaasch(a)apple.com>
Signed-off-by: Paolo Abeni <pabeni(a)redhat.com>
---
 net/mptcp/protocol.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 254e6ef2b4e0..2936413171be 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1944,6 +1944,13 @@ static int mptcp_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 	return err;
 }
 
+static void mptcp_subflow_early_fallback(struct mptcp_sock *msk,
+					 struct mptcp_subflow_context *subflow)
+{
+	subflow->request_mptcp = 0;
+	__mptcp_do_fallback(msk);
+}
+
 static int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr,
 				int addr_len, int flags)
 {
@@ -1975,10 +1982,10 @@ static int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr,
 	 * TCP option space.
 	 */
 	if (rcu_access_pointer(tcp_sk(ssock->sk)->md5sig_info))
-		subflow->request_mptcp = 0;
+		mptcp_subflow_early_fallback(msk, subflow);
 #endif
 	if (subflow->request_mptcp && mptcp_token_new_connect(ssock->sk))
-		subflow->request_mptcp = 0;
+		mptcp_subflow_early_fallback(msk, subflow);
 
 do_connect:
 	err = ssock->ops->connect(ssock, uaddr, addr_len, flags);
-- 
2.26.2

WARNING: multiple messages have this Message-ID (diff)
From: Paolo Abeni <pabeni@redhat.com>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>, mptcp@lists.01.org
Subject: [PATCH net-next 3/8] mptcp: mark as fallback even early ones
Date: Thu, 23 Jul 2020 13:02:31 +0200	[thread overview]
Message-ID: <1fa72209d016ee555828b18bc3675784d416d543.1595431326.git.pabeni@redhat.com> (raw)
In-Reply-To: <cover.1595431326.git.pabeni@redhat.com>

In the unlikely event of a failure at connect time,
we currently clear the request_mptcp flag - so that
the MPC handshake is not started at all, but the msk
is not explicitly marked as fallback.

This would lead to later insertion of wrong DSS options
in the xmitted packets, in violation of RFC specs and
possibly fooling the peer.

Fixes: e1ff9e82e2ea ("net: mptcp: improve fallback to TCP")
Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Tested-by: Christoph Paasch <cpaasch@apple.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/mptcp/protocol.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 254e6ef2b4e0..2936413171be 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1944,6 +1944,13 @@ static int mptcp_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 	return err;
 }
 
+static void mptcp_subflow_early_fallback(struct mptcp_sock *msk,
+					 struct mptcp_subflow_context *subflow)
+{
+	subflow->request_mptcp = 0;
+	__mptcp_do_fallback(msk);
+}
+
 static int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr,
 				int addr_len, int flags)
 {
@@ -1975,10 +1982,10 @@ static int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr,
 	 * TCP option space.
 	 */
 	if (rcu_access_pointer(tcp_sk(ssock->sk)->md5sig_info))
-		subflow->request_mptcp = 0;
+		mptcp_subflow_early_fallback(msk, subflow);
 #endif
 	if (subflow->request_mptcp && mptcp_token_new_connect(ssock->sk))
-		subflow->request_mptcp = 0;
+		mptcp_subflow_early_fallback(msk, subflow);
 
 do_connect:
 	err = ssock->ops->connect(ssock, uaddr, addr_len, flags);
-- 
2.26.2


             reply	other threads:[~2020-07-23 11:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23 11:02 Paolo Abeni [this message]
2020-07-23 11:02 ` [PATCH net-next 3/8] mptcp: mark as fallback even early ones Paolo Abeni
  -- strict thread matches above, loose matches on Subject: below --
2020-07-23 18:47 [MPTCP] Re: [PATCH net-next 0/8] mptcp: non backup subflows pre-reqs David Miller
2020-07-23 18:47 ` David Miller
2020-07-23 11:02 [MPTCP] [PATCH net-next 8/8] subflow: introduce and use mptcp_can_accept_new_subflow() Paolo Abeni
2020-07-23 11:02 ` Paolo Abeni
2020-07-23 11:02 [MPTCP] [PATCH net-next 7/8] subflow: use rsk_ops->send_reset() Paolo Abeni
2020-07-23 11:02 ` Paolo Abeni
2020-07-23 11:02 [MPTCP] [PATCH net-next 6/8] subflow: explicitly check for plain tcp rsk Paolo Abeni
2020-07-23 11:02 ` Paolo Abeni
2020-07-23 11:02 [MPTCP] [PATCH net-next 5/8] mptcp: cleanup subflow_finish_connect() Paolo Abeni
2020-07-23 11:02 ` Paolo Abeni
2020-07-23 11:02 [MPTCP] [PATCH net-next 4/8] mptcp: explicitly track the fully established status Paolo Abeni
2020-07-23 11:02 ` Paolo Abeni
2020-07-23 11:02 [MPTCP] [PATCH net-next 2/8] mptcp: avoid data corruption on reinsert Paolo Abeni
2020-07-23 11:02 ` Paolo Abeni
2020-07-23 11:02 [MPTCP] [PATCH net-next 1/8] subflow: always init 'rel_write_seq' Paolo Abeni
2020-07-23 11:02 ` Paolo Abeni
2020-07-23 11:02 [MPTCP] [PATCH net-next 0/8] mptcp: non backup subflows pre-reqs Paolo Abeni
2020-07-23 11:02 ` Paolo Abeni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1fa72209d016ee555828b18bc3675784d416d543.1595431326.git.pabeni@redhat.com \
    --to=unknown@example.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.