From: Jason Dillaman Date: Wed, 12 Feb 2020 02:59:41 +0000 (-0500) Subject: rbd-mirror: prevent asok commands from dereferencing uninitialized members X-Git-Tag: v14.2.10~185^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=32dc95091f1fa32ac9e52ee0a3a0813b9bc09ca7;p=ceph.git rbd-mirror: prevent asok commands from dereferencing uninitialized members If rbd-mirror fails to connect to the remote cluster, there is a window of time where the asok commands might attempt to dereference the default namespace replayer or access invalid librados IoCtxs. Signed-off-by: Jason Dillaman (cherry picked from commit a3a11a21cc977291253391b6279734c48958408d) Conflicts: src/tools/rbd_mirror/PoolReplayer.cc - s/m_default_namespace_replayer/m_instance_replayer/g --- diff --git a/src/tools/rbd_mirror/PoolReplayer.cc b/src/tools/rbd_mirror/PoolReplayer.cc index ac346325670..95ffa2073bb 100644 --- a/src/tools/rbd_mirror/PoolReplayer.cc +++ b/src/tools/rbd_mirror/PoolReplayer.cc @@ -591,9 +591,11 @@ void PoolReplayer::print_status(Formatter *f, stringstream *ss) Mutex::Locker l(m_lock); f->open_object_section("pool_replayer_status"); - f->dump_string("pool", m_local_io_ctx.get_pool_name()); f->dump_stream("peer") << m_peer; - f->dump_string("instance_id", m_instance_watcher->get_instance_id()); + if (m_local_io_ctx.is_valid()) { + f->dump_string("pool", m_local_io_ctx.get_pool_name()); + f->dump_stream("instance_id") << m_instance_watcher->get_instance_id(); + } std::string state("running"); if (m_manual_stop) { @@ -654,7 +656,10 @@ void PoolReplayer::start() } m_manual_stop = false; - m_instance_replayer->start(); + + if (m_instance_replayer) { + m_instance_replayer->start(); + } } template @@ -672,7 +677,10 @@ void PoolReplayer::stop(bool manual) } m_manual_stop = true; - m_instance_replayer->stop(); + + if (m_instance_replayer) { + m_instance_replayer->stop(); + } } template @@ -686,7 +694,9 @@ void PoolReplayer::restart() return; } - m_instance_replayer->restart(); + if (m_instance_replayer) { + m_instance_replayer->restart(); + } } template @@ -700,7 +710,9 @@ void PoolReplayer::flush() return; } - m_instance_replayer->flush(); + if (m_instance_replayer) { + m_instance_replayer->flush(); + } } template