]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: prevent asok commands from dereferencing uninitialized members
authorJason Dillaman <dillaman@redhat.com>
Wed, 12 Feb 2020 02:59:41 +0000 (21:59 -0500)
committerNathan Cutler <ncutler@suse.com>
Fri, 14 Feb 2020 15:04:35 +0000 (16:04 +0100)
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 <dillaman@redhat.com>
(cherry picked from commit a3a11a21cc977291253391b6279734c48958408d)

Conflicts:
src/tools/rbd_mirror/PoolReplayer.cc
- s/m_default_namespace_replayer/m_instance_replayer/g

src/tools/rbd_mirror/PoolReplayer.cc

index ac3463256704a9f95fa67ac953b53fb9a5823f8d..95ffa2073bbf0276ebbfa699844c989c00eb34b3 100644 (file)
@@ -591,9 +591,11 @@ void PoolReplayer<I>::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<I>::start()
   }
 
   m_manual_stop = false;
-  m_instance_replayer->start();
+
+  if (m_instance_replayer) {
+    m_instance_replayer->start();
+  }
 }
 
 template <typename I>
@@ -672,7 +677,10 @@ void PoolReplayer<I>::stop(bool manual)
   }
 
   m_manual_stop = true;
-  m_instance_replayer->stop();
+
+  if (m_instance_replayer) {
+    m_instance_replayer->stop();
+  }
 }
 
 template <typename I>
@@ -686,7 +694,9 @@ void PoolReplayer<I>::restart()
     return;
   }
 
-  m_instance_replayer->restart();
+  if (m_instance_replayer) {
+    m_instance_replayer->restart();
+  }
 }
 
 template <typename I>
@@ -700,7 +710,9 @@ void PoolReplayer<I>::flush()
     return;
   }
 
-  m_instance_replayer->flush();
+  if (m_instance_replayer) {
+    m_instance_replayer->flush();
+  }
 }
 
 template <typename I>