summaryrefslogtreecommitdiff
path: root/drivers/md/dm-zoned-metadata.c
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2020-06-02 14:09:56 +0300
committerMike Snitzer <snitzer@redhat.com>2020-06-05 21:59:54 +0300
commit27d49ac1dd751897506ba51df7226fc0ce7ef681 (patch)
tree6ce06acd58dc57a7a2e40294050e6b4a9682fd6b /drivers/md/dm-zoned-metadata.c
parent2094045fe5b5dda98c4ec6cb1ac7b12ba4382856 (diff)
downloadlinux-27d49ac1dd751897506ba51df7226fc0ce7ef681.tar.xz
dm zoned: check superblock location
When specifying several devices the superblock location must be checked to ensure the devices are specified in the correct order. Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-zoned-metadata.c')
-rw-r--r--drivers/md/dm-zoned-metadata.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
index 59a34895f5a8..314ce31a2c43 100644
--- a/drivers/md/dm-zoned-metadata.c
+++ b/drivers/md/dm-zoned-metadata.c
@@ -997,7 +997,7 @@ static int dmz_check_sb(struct dmz_metadata *zmd, struct dmz_sb *dsb,
struct dmz_dev *dev = dsb->dev;
unsigned int nr_meta_zones, nr_data_zones;
u32 crc, stored_crc;
- u64 gen;
+ u64 gen, sb_block;
if (le32_to_cpu(sb->magic) != DMZ_MAGIC) {
dmz_dev_err(dev, "Invalid meta magic (needed 0x%08x, got 0x%08x)",
@@ -1026,6 +1026,14 @@ static int dmz_check_sb(struct dmz_metadata *zmd, struct dmz_sb *dsb,
return -ENXIO;
}
+ sb_block = le64_to_cpu(sb->sb_block);
+ if (sb_block != (u64)dsb->zone->id << zmd->zone_nr_blocks_shift ) {
+ dmz_dev_err(dev, "Invalid superblock position "
+ "(is %llu expected %llu)",
+ sb_block,
+ (u64)dsb->zone->id << zmd->zone_nr_blocks_shift);
+ return -EINVAL;
+ }
if (zmd->sb_version > 1) {
uuid_t sb_uuid;