* [PATCH net] mptcp: fix locking in mptcp_disconnect()
@ 2021-01-14 15:37 Paolo Abeni
2021-01-14 19:21 ` Eric Dumazet
2021-01-14 19:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Paolo Abeni @ 2021-01-14 15:37 UTC (permalink / raw)
To: netdev; +Cc: mptcp, David S. Miller, Jakub Kicinski, Eric Dumazet
tcp_disconnect() expects the caller acquires the sock lock,
but mptcp_disconnect() is not doing that. Add the missing
required lock.
Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Fixes: 76e2a55d1625 ("mptcp: better msk-level shutdown.")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
net/mptcp/protocol.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 81faeff8f3bb..f998a077c7dd 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2646,8 +2646,13 @@ static int mptcp_disconnect(struct sock *sk, int flags)
struct mptcp_sock *msk = mptcp_sk(sk);
__mptcp_flush_join_list(msk);
- mptcp_for_each_subflow(msk, subflow)
- tcp_disconnect(mptcp_subflow_tcp_sock(subflow), flags);
+ mptcp_for_each_subflow(msk, subflow) {
+ struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
+
+ lock_sock(ssk);
+ tcp_disconnect(ssk, flags);
+ release_sock(ssk);
+ }
return 0;
}
--
2.26.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] mptcp: fix locking in mptcp_disconnect()
2021-01-14 15:37 [PATCH net] mptcp: fix locking in mptcp_disconnect() Paolo Abeni
@ 2021-01-14 19:21 ` Eric Dumazet
2021-01-14 19:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2021-01-14 19:21 UTC (permalink / raw)
To: Paolo Abeni, netdev; +Cc: mptcp, David S. Miller, Jakub Kicinski, Eric Dumazet
On 1/14/21 4:37 PM, Paolo Abeni wrote:
> tcp_disconnect() expects the caller acquires the sock lock,
> but mptcp_disconnect() is not doing that. Add the missing
> required lock.
>
> Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
> Fixes: 76e2a55d1625 ("mptcp: better msk-level shutdown.")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---
> net/mptcp/protocol.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 81faeff8f3bb..f998a077c7dd 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -2646,8 +2646,13 @@ static int mptcp_disconnect(struct sock *sk, int flags)
> struct mptcp_sock *msk = mptcp_sk(sk);
>
> __mptcp_flush_join_list(msk);
> - mptcp_for_each_subflow(msk, subflow)
> - tcp_disconnect(mptcp_subflow_tcp_sock(subflow), flags);
> + mptcp_for_each_subflow(msk, subflow) {
> + struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
> +
> + lock_sock(ssk);
> + tcp_disconnect(ssk, flags);
> + release_sock(ssk);
> + }
Reviewed-by: Eric Dumazet <edumazet@google.com>
Note that for loops like this one, calling non blocking functions,
you could use lock_sock_fast()
(Probably does not matter in slow path)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] mptcp: fix locking in mptcp_disconnect()
2021-01-14 15:37 [PATCH net] mptcp: fix locking in mptcp_disconnect() Paolo Abeni
2021-01-14 19:21 ` Eric Dumazet
@ 2021-01-14 19:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-01-14 19:30 UTC (permalink / raw)
To: Paolo Abeni; +Cc: netdev, mptcp, davem, kuba, eric.dumazet
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
On Thu, 14 Jan 2021 16:37:37 +0100 you wrote:
> tcp_disconnect() expects the caller acquires the sock lock,
> but mptcp_disconnect() is not doing that. Add the missing
> required lock.
>
> Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
> Fixes: 76e2a55d1625 ("mptcp: better msk-level shutdown.")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
>
> [...]
Here is the summary with links:
- [net] mptcp: fix locking in mptcp_disconnect()
https://git.kernel.org/netdev/net/c/13a9499e8333
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-14 19:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-14 15:37 [PATCH net] mptcp: fix locking in mptcp_disconnect() Paolo Abeni
2021-01-14 19:21 ` Eric Dumazet
2021-01-14 19:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).