Commit a2790b99 authored by Qu Wenruo's avatar Qu Wenruo Committed by Greg Kroah-Hartman

btrfs: volumes: Make sure no dev extent is beyond device boundary

[ Upstream commit 05a37c48 ]

Add extra dev extent end check against device boundary.
Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent cfbf227e
...@@ -7411,6 +7411,7 @@ static int verify_one_dev_extent(struct btrfs_fs_info *fs_info, ...@@ -7411,6 +7411,7 @@ static int verify_one_dev_extent(struct btrfs_fs_info *fs_info,
struct extent_map_tree *em_tree = &fs_info->mapping_tree.map_tree; struct extent_map_tree *em_tree = &fs_info->mapping_tree.map_tree;
struct extent_map *em; struct extent_map *em;
struct map_lookup *map; struct map_lookup *map;
struct btrfs_device *dev;
u64 stripe_len; u64 stripe_len;
bool found = false; bool found = false;
int ret = 0; int ret = 0;
...@@ -7460,6 +7461,22 @@ static int verify_one_dev_extent(struct btrfs_fs_info *fs_info, ...@@ -7460,6 +7461,22 @@ static int verify_one_dev_extent(struct btrfs_fs_info *fs_info,
physical_offset, devid); physical_offset, devid);
ret = -EUCLEAN; ret = -EUCLEAN;
} }
/* Make sure no dev extent is beyond device bondary */
dev = btrfs_find_device(fs_info, devid, NULL, NULL);
if (!dev) {
btrfs_err(fs_info, "failed to find devid %llu", devid);
ret = -EUCLEAN;
goto out;
}
if (physical_offset + physical_len > dev->disk_total_bytes) {
btrfs_err(fs_info,
"dev extent devid %llu physical offset %llu len %llu is beyond device boundary %llu",
devid, physical_offset, physical_len,
dev->disk_total_bytes);
ret = -EUCLEAN;
goto out;
}
out: out:
free_extent_map(em); free_extent_map(em);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment