Message ID | f818e82b58a556feeb71dcccc8bf1c87aafc6175.1610638176.git.pabeni@redhat.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 13a9499e833387fcc7a53915bbe5cddf3c336b59 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] mptcp: fix locking in mptcp_disconnect() | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 2 maintainers not CCed: matthieu.baerts@tessares.net mathew.j.martineau@linux.intel.com |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 2 this patch: 2 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 15 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 2 this patch: 2 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
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)
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
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; }
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(-)