]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/cephfs: detect malformed ESubtreeMap::expire_pos
authorJohn Spray <john.spray@redhat.com>
Thu, 24 Sep 2015 12:08:43 +0000 (13:08 +0100)
committerJohn Spray <john.spray@redhat.com>
Thu, 24 Sep 2015 12:12:03 +0000 (13:12 +0100)
Signed-off-by: John Spray <john.spray@redhat.com>
src/tools/cephfs/JournalScanner.cc

index f75edd9b29ff8b4ef8fb82b4834ef197fc08b235..f2d22d0c230d4686d4f05731c546148eb3817135 100644 (file)
@@ -15,6 +15,8 @@
 #include "include/rados/librados.hpp"
 #include "mds/JournalPointer.h"
 
+#include "mds/events/ESubtreeMap.h"
+
 #include "JournalScanner.h"
 
 #define dout_subsys ceph_subsys_mds
@@ -256,9 +258,21 @@ int JournalScanner::scan_events()
         }
 
         LogEvent *le = LogEvent::decode(le_bl);
+
         if (le) {
           dout(10) << "Valid entry at 0x" << std::hex << read_offset << std::dec << dendl;
 
+          if (le->get_type() == EVENT_SUBTREEMAP
+              || le->get_type() == EVENT_SUBTREEMAP_TEST) {
+            ESubtreeMap *sle = dynamic_cast<ESubtreeMap*>(le);
+            if (sle->expire_pos > read_offset) {
+              errors.insert(std::make_pair(
+                    read_offset, EventError(
+                      -ERANGE,
+                      "ESubtreeMap has expire_pos ahead of its own position")));
+            }
+          }
+
           if (filter.apply(read_offset, *le)) {
             events[read_offset] = EventRecord(le, consumed);
           } else {