Commit b7a679ba authored by Paolo Abeni's avatar Paolo Abeni Committed by Jakub Kicinski

mptcp: fix possible deadlock in subflow_error_report

Christoph reported a possible deadlock while the TCP stack
destroys an unaccepted subflow due to an incoming reset: the
MPTCP socket error path tries to acquire the msk-level socket
lock while TCP still owns the listener socket accept queue
spinlock, and the reverse dependency already exists in the
TCP stack.

Note that the above is actually a lockdep false positive, as
the chain involves two separate sockets. A different per-socket
lockdep key will address the issue, but such a change will be
quite invasive.

Instead, we can simply stop earlier the socket error handling
for orphaned or unaccepted subflows, breaking the critical
lockdep chain. Error handling in such a scenario is a no-op.
Reported-and-tested-by: default avatarChristoph Paasch <cpaasch@apple.com>
Fixes: 15cc1045 ("mptcp: deliver ssk errors to msk")
Cc: stable@vger.kernel.org
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/355Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Reviewed-by: default avatarMatthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: default avatarMatthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 12508b3e
...@@ -1432,6 +1432,13 @@ static void subflow_error_report(struct sock *ssk) ...@@ -1432,6 +1432,13 @@ static void subflow_error_report(struct sock *ssk)
{ {
struct sock *sk = mptcp_subflow_ctx(ssk)->conn; struct sock *sk = mptcp_subflow_ctx(ssk)->conn;
/* bail early if this is a no-op, so that we avoid introducing a
* problematic lockdep dependency between TCP accept queue lock
* and msk socket spinlock
*/
if (!sk->sk_socket)
return;
mptcp_data_lock(sk); mptcp_data_lock(sk);
if (!sock_owned_by_user(sk)) if (!sock_owned_by_user(sk))
__mptcp_error_report(sk); __mptcp_error_report(sk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment