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: v15.1.1~437^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a3a11a21cc977291253391b6279734c48958408d;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 --- diff --git a/src/tools/rbd_mirror/PoolReplayer.cc b/src/tools/rbd_mirror/PoolReplayer.cc index 416ca4ba9f70..24bd036184eb 100644 --- a/src/tools/rbd_mirror/PoolReplayer.cc +++ b/src/tools/rbd_mirror/PoolReplayer.cc @@ -817,9 +817,11 @@ void PoolReplayer::print_status(Formatter *f) { std::lock_guard 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_stream("instance_id") << m_local_io_ctx.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_local_io_ctx.get_instance_id(); + } std::string state("running"); if (m_manual_stop) { @@ -900,7 +902,9 @@ void PoolReplayer::start() { m_manual_stop = false; - m_default_namespace_replayer->start(); + if (m_default_namespace_replayer) { + m_default_namespace_replayer->start(); + } for (auto &it : m_namespace_replayers) { it.second->start(); } @@ -921,7 +925,9 @@ void PoolReplayer::stop(bool manual) { m_manual_stop = true; - m_default_namespace_replayer->stop(); + if (m_default_namespace_replayer) { + m_default_namespace_replayer->stop(); + } for (auto &it : m_namespace_replayers) { it.second->stop(); } @@ -937,7 +943,9 @@ void PoolReplayer::restart() { return; } - m_default_namespace_replayer->restart(); + if (m_default_namespace_replayer) { + m_default_namespace_replayer->restart(); + } for (auto &it : m_namespace_replayers) { it.second->restart(); } @@ -953,7 +961,9 @@ void PoolReplayer::flush() { return; } - m_default_namespace_replayer->flush(); + if (m_default_namespace_replayer) { + m_default_namespace_replayer->flush(); + } for (auto &it : m_namespace_replayers) { it.second->flush(); }