From 0be2c26a25bf3ca6c5207738f303d77f34e67e70 Mon Sep 17 00:00:00 2001 From: Adam Kupczyk Date: Tue, 9 Nov 2021 13:01:23 +0100 Subject: [PATCH] os/bluestore: Protect _clone against sudden omap format changes Added assert to verify that omap prefixes between cloned objects are exactly the same. If they would differ rewrite_omap_key() will possibly overwrite user key potion of data, or move some part of prefix into user key. This is a follow up from https://github.com/ceph/ceph/pull/43687 Signed-off-by: Adam Kupczyk --- src/os/bluestore/BlueStore.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 309a3af3c8e..371f92220aa 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -16150,6 +16150,9 @@ int BlueStore::_clone(TransContext *txc, } else { newo->onode.set_omap_flags(per_pool_omap == OMAP_BULK); } + // check if prefix for omap key is exactly the same size for both objects + // otherwise rewrite_omap_key will corrupt data + ceph_assert(oldo->onode.flags == newo->onode.flags); const string& prefix = newo->get_omap_prefix(); KeyValueDB::Iterator it = db->get_iterator(prefix); string head, tail; -- 2.39.5