From: Sage Weil Date: Tue, 8 Jan 2019 13:13:13 +0000 (-0600) Subject: msg/async/Protocol*: fix mark_down vs accept race X-Git-Tag: v14.1.0~462^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a1613e60a0a6a78bd9ccd09b410b47f5123d844b;p=ceph.git msg/async/Protocol*: fix mark_down vs accept race If we mark_down the connection while we have the lock dropped the state maybe CLOSED when we retake it. Bail out if that happens instead of continuing to process the connection and eventually running into an assertion on can_write. Fixes: http://tracker.ceph.com/issues/36497 Signed-off-by: Sage Weil --- diff --git a/src/msg/async/ProtocolV1.cc b/src/msg/async/ProtocolV1.cc index ab4b526105f..0d71148ffbd 100644 --- a/src/msg/async/ProtocolV1.cc +++ b/src/msg/async/ProtocolV1.cc @@ -1933,6 +1933,13 @@ CtPtr ProtocolV1::handle_connect_message_2() { need_challenge ? &authorizer_challenge : nullptr) || !authorizer_valid) { connection->lock.lock(); + if (state != ACCEPTING_WAIT_CONNECT_MSG_AUTH) { + ldout(cct, 1) << __func__ + << " state changed while accept, it must be mark_down" + << dendl; + ceph_assert(state == CLOSED); + return _fault(); + } if (need_challenge && !had_challenge && authorizer_challenge) { ldout(cct, 10) << __func__ << ": challenging authorizer" << dendl; diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc index 99b424e6dbc..526545d6ea8 100644 --- a/src/msg/async/ProtocolV2.cc +++ b/src/msg/async/ProtocolV2.cc @@ -1980,6 +1980,13 @@ CtPtr ProtocolV2::handle_connect_message_2() { need_challenge ? &authorizer_challenge : nullptr) || !authorizer_valid) { connection->lock.lock(); + if (state != ACCEPTING_WAIT_CONNECT_MSG_AUTH) { + ldout(cct, 1) << __func__ + << " state changed while accept, it must be mark_down" + << dendl; + ceph_assert(state == CLOSED); + return _fault(); + } if (need_challenge && !had_challenge && authorizer_challenge) { ldout(cct, 10) << __func__ << ": challenging authorizer" << dendl;