]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
radosgw-admin: bucket sync status guards against shard count mismatch
authorCasey Bodley <cbodley@redhat.com>
Fri, 20 Aug 2021 14:39:34 +0000 (10:39 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Tue, 1 Feb 2022 22:44:17 +0000 (17:44 -0500)
if the remote gives us more shards than we expect, just count those
shards as 'behind' and avoid out-of-bounds access of shard_status

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_admin.cc

index 7e4c31e9d2ab43047f561d2ae984d367ea3825ee..4994f67d143d748e20871ad5165e2eac791aa114 100644 (file)
@@ -2576,12 +2576,17 @@ static int bucket_source_sync_status(const DoutPrefixProvider *dpp, rgw::sal::Ra
   }
 
   std::set<int> shards_behind;
-  for (auto& r : remote_markers.get()) {
+  for (const auto& r : remote_markers.get()) {
     auto shard_id = r.first;
-    auto& m = shard_status[shard_id];
     if (r.second.empty()) {
       continue; // empty bucket index shard
     }
+    if (shard_id >= total_shards) {
+      // unexpected shard id. we don't have status for it, so we're behind
+      shards_behind.insert(shard_id);
+      continue;
+    }
+    auto& m = shard_status[shard_id];
     const auto pos = BucketIndexShardsManager::get_shard_marker(m.inc_marker.position);
     if (pos < r.second) {
       shards_behind.insert(shard_id);