mptcp: avoid race on msk state changes
authorPaolo Abeni <pabeni@redhat.com>
Tue, 22 Jun 2021 00:33:08 +0000 (17:33 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 22 Jun 2021 17:22:42 +0000 (10:22 -0700)
commit490274b47468793e3e157c2df6b2da0e646cc4a9
treeb9e59a12ecd1f2169d00e68b1789910b3c42c8b3
parent3ddd6e2f71092766b6040b9c33cf9906577b4025
mptcp: avoid race on msk state changes

The msk socket state is currently updated in a few spots without
owning the msk socket lock itself.

Some of such operations are safe, as they happens before exposing
the msk socket to user-space and can't race with other changes.

A couple of them, at connect time, can actually race with close()
or shutdown(), leaving breaking the socket state machine.

This change addresses the issue moving such update under the msk
socket lock with the usual:

<acquire spinlock>
<check sk lock onwers>
<ev defer to release_cb>

scheme.

Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/56
Fixes: 8fd738049ac3 ("mptcp: fallback in case of simultaneous connect")
Fixes: c3c123d16c0e ("net: mptcp: don't hang in mptcp_sendmsg() after TCP fallback")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/mptcp/protocol.c
net/mptcp/protocol.h
net/mptcp/subflow.c