* FAILED: patch "[PATCH] mptcp: do not rely on implicit state check in mptcp_listen()" failed to apply to 6.1-stable tree
@ 2023-07-21 14:36 gregkh
2023-07-27 14:16 ` [PATCH 6.1.y] mptcp: do not rely on implicit state check in mptcp_listen() Matthieu Baerts
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2023-07-21 14:36 UTC (permalink / raw)
To: pabeni, cpaasch, davem, matthieu.baerts; +Cc: stable
The patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 0226436acf2495cde4b93e7400e5a87305c26054
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2023072119-skipping-penalize-15f0@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
0226436acf24 ("mptcp: do not rely on implicit state check in mptcp_listen()")
cfdcfeed6449 ("mptcp: introduce 'sk' to replace 'sock->sk' in mptcp_listen()")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 0226436acf2495cde4b93e7400e5a87305c26054 Mon Sep 17 00:00:00 2001
From: Paolo Abeni <pabeni@redhat.com>
Date: Tue, 4 Jul 2023 22:44:34 +0200
Subject: [PATCH] mptcp: do not rely on implicit state check in mptcp_listen()
Since the blamed commit, closing the first subflow resets the first
subflow socket state to SS_UNCONNECTED.
The current mptcp listen implementation relies only on such
state to prevent touching not-fully-disconnected sockets.
Incoming mptcp fastclose (or paired endpoint removal) unconditionally
closes the first subflow.
All the above allows an incoming fastclose followed by a listen() call
to successfully race with a blocking recvmsg(), potentially causing the
latter to hit a divide by zero bug in cleanup_rbuf/__tcp_select_window().
Address the issue explicitly checking the msk socket state in
mptcp_listen(). An alternative solution would be moving the first
subflow socket state update into mptcp_disconnect(), but in the long
term the first subflow socket should be removed: better avoid relaying
on it for internal consistency check.
Fixes: b29fcfb54cd7 ("mptcp: full disconnect implementation")
Cc: stable@vger.kernel.org
Reported-by: Christoph Paasch <cpaasch@apple.com>
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/414
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 489a3defdde5..3613489eb6e3 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3703,6 +3703,11 @@ static int mptcp_listen(struct socket *sock, int backlog)
pr_debug("msk=%p", msk);
lock_sock(sk);
+
+ err = -EINVAL;
+ if (sock->state != SS_UNCONNECTED || sock->type != SOCK_STREAM)
+ goto unlock;
+
ssock = __mptcp_nmpc_socket(msk);
if (IS_ERR(ssock)) {
err = PTR_ERR(ssock);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 6.1.y] mptcp: do not rely on implicit state check in mptcp_listen()
2023-07-21 14:36 FAILED: patch "[PATCH] mptcp: do not rely on implicit state check in mptcp_listen()" failed to apply to 6.1-stable tree gregkh
@ 2023-07-27 14:16 ` Matthieu Baerts
2023-07-28 14:59 ` Matthieu Baerts
0 siblings, 1 reply; 3+ messages in thread
From: Matthieu Baerts @ 2023-07-27 14:16 UTC (permalink / raw)
To: stable, gregkh
Cc: MPTCP Upstream, Paolo Abeni, Christoph Paasch, Matthieu Baerts,
David S . Miller
From: Paolo Abeni <pabeni@redhat.com>
commit 0226436acf2495cde4b93e7400e5a87305c26054 upstream.
Since the blamed commit, closing the first subflow resets the first
subflow socket state to SS_UNCONNECTED.
The current mptcp listen implementation relies only on such
state to prevent touching not-fully-disconnected sockets.
Incoming mptcp fastclose (or paired endpoint removal) unconditionally
closes the first subflow.
All the above allows an incoming fastclose followed by a listen() call
to successfully race with a blocking recvmsg(), potentially causing the
latter to hit a divide by zero bug in cleanup_rbuf/__tcp_select_window().
Address the issue explicitly checking the msk socket state in
mptcp_listen(). An alternative solution would be moving the first
subflow socket state update into mptcp_disconnect(), but in the long
term the first subflow socket should be removed: better avoid relaying
on it for internal consistency check.
Fixes: b29fcfb54cd7 ("mptcp: full disconnect implementation")
Cc: stable@vger.kernel.org
Reported-by: Christoph Paasch <cpaasch@apple.com>
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/414
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
Backport notes:
- Conflicting with a cleanup that has been done after v6.1, see commit
cfdcfeed6449 ("mptcp: introduce 'sk' to replace 'sock->sk' in
mptcp_listen()").
- The conflict was in the context and the new lines didn't need to be
adapted.
---
net/mptcp/protocol.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index a6a5c16f2a49..b76cda4187bc 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3752,6 +3752,11 @@ static int mptcp_listen(struct socket *sock, int backlog)
pr_debug("msk=%p", msk);
lock_sock(sock->sk);
+
+ err = -EINVAL;
+ if (sock->state != SS_UNCONNECTED || sock->type != SOCK_STREAM)
+ goto unlock;
+
ssock = __mptcp_nmpc_socket(msk);
if (!ssock) {
err = -EINVAL;
--
2.40.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 6.1.y] mptcp: do not rely on implicit state check in mptcp_listen()
2023-07-27 14:16 ` [PATCH 6.1.y] mptcp: do not rely on implicit state check in mptcp_listen() Matthieu Baerts
@ 2023-07-28 14:59 ` Matthieu Baerts
0 siblings, 0 replies; 3+ messages in thread
From: Matthieu Baerts @ 2023-07-28 14:59 UTC (permalink / raw)
To: stable, gregkh, Sasha Levin
Cc: MPTCP Upstream, Paolo Abeni, Christoph Paasch, David S . Miller
Hi Greg, Sasha,
On 27/07/2023 16:16, Matthieu Baerts wrote:
> From: Paolo Abeni <pabeni@redhat.com>
>
> commit 0226436acf2495cde4b93e7400e5a87305c26054 upstream.
>
> Since the blamed commit, closing the first subflow resets the first
> subflow socket state to SS_UNCONNECTED.
>
> The current mptcp listen implementation relies only on such
> state to prevent touching not-fully-disconnected sockets.
>
> Incoming mptcp fastclose (or paired endpoint removal) unconditionally
> closes the first subflow.
>
> All the above allows an incoming fastclose followed by a listen() call
> to successfully race with a blocking recvmsg(), potentially causing the
> latter to hit a divide by zero bug in cleanup_rbuf/__tcp_select_window().
>
> Address the issue explicitly checking the msk socket state in
> mptcp_listen(). An alternative solution would be moving the first
> subflow socket state update into mptcp_disconnect(), but in the long
> term the first subflow socket should be removed: better avoid relaying
> on it for internal consistency check.
>
> Fixes: b29fcfb54cd7 ("mptcp: full disconnect implementation")
> Cc: stable@vger.kernel.org
> Reported-by: Christoph Paasch <cpaasch@apple.com>
> Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/414
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> ---
> Backport notes:
> - Conflicting with a cleanup that has been done after v6.1, see commit
> cfdcfeed6449 ("mptcp: introduce 'sk' to replace 'sock->sk' in
> mptcp_listen()").
Sasha just backported this commit cfdcfeed6449 ("mptcp: introduce 'sk'
to replace 'sock->sk' in mptcp_listen()") so 0226436acf24 ("mptcp: do
not rely on implicit state check in mptcp_listen()") can be applied
without conflict. Thank you for that, good idea, it works for me!
Please drop this patch here then.
Cheers,
Matt
--
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-28 14:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-21 14:36 FAILED: patch "[PATCH] mptcp: do not rely on implicit state check in mptcp_listen()" failed to apply to 6.1-stable tree gregkh
2023-07-27 14:16 ` [PATCH 6.1.y] mptcp: do not rely on implicit state check in mptcp_listen() Matthieu Baerts
2023-07-28 14:59 ` Matthieu Baerts
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox