Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Paolo Abeni <pabeni@redhat.com>, netdev@vger.kernel.org
Cc: mptcp@lists.01.org, "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Eric Dumazet <eric.dumazet@gmail.com>
Subject: Re: [PATCH net] mptcp: fix locking in mptcp_disconnect()
Date: Thu, 14 Jan 2021 20:21:48 +0100	[thread overview]
Message-ID: <9cf07f1b-c013-adfc-15b4-58902095cf07@gmail.com> (raw)
In-Reply-To: <f818e82b58a556feeb71dcccc8bf1c87aafc6175.1610638176.git.pabeni@redhat.com>



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)


  reply	other threads:[~2021-01-14 19:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-14 15:37 [PATCH net] mptcp: fix locking in mptcp_disconnect() Paolo Abeni
2021-01-14 19:21 ` Eric Dumazet [this message]
2021-01-14 19:30 ` patchwork-bot+netdevbpf

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=9cf07f1b-c013-adfc-15b4-58902095cf07@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=mptcp@lists.01.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox