linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] btrfs-progs: btrfs-convert: Prevent accounting blocks beyond end of device
@ 2016-12-08 13:56 Chandan Rajendra
  2016-12-08 13:56 ` [PATCH 2/2] btrfs-convert: Fix migrate_super_block() to work with 64k sectorsize Chandan Rajendra
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Chandan Rajendra @ 2016-12-08 13:56 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Chandan Rajendra, dsterba

When looping across data block bitmap, __ext2_add_one_block() may add
blocks which do not exist on the underlying disk. This commit prevents
this from happening by checking the block index against the maximum
block count that was present in the ext4 filesystem instance that is
being converted.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
---
 convert/main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/convert/main.c b/convert/main.c
index 4b4cea4..1148a36 100644
--- a/convert/main.c
+++ b/convert/main.c
@@ -1525,6 +1525,9 @@ static int __ext2_add_one_block(ext2_filsys fs, char *bitmap,
 	offset /= EXT2FS_CLUSTER_RATIO(fs);
 	offset += group_nr * EXT2_CLUSTERS_PER_GROUP(fs->super);
 	for (i = 0; i < EXT2_CLUSTERS_PER_GROUP(fs->super); i++) {
+		if ((i + offset) >= ext2fs_blocks_count(fs->super))
+			break;
+
 		if (ext2fs_test_bit(i, bitmap)) {
 			u64 start;
 
-- 
2.5.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-12-14 12:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-08 13:56 [PATCH 1/2] btrfs-progs: btrfs-convert: Prevent accounting blocks beyond end of device Chandan Rajendra
2016-12-08 13:56 ` [PATCH 2/2] btrfs-convert: Fix migrate_super_block() to work with 64k sectorsize Chandan Rajendra
2016-12-09  1:09   ` Qu Wenruo
2016-12-09  5:15     ` Chandan Rajendra
2016-12-14 12:38     ` David Sterba
2016-12-09  1:03 ` [PATCH 1/2] btrfs-progs: btrfs-convert: Prevent accounting blocks beyond end of device Qu Wenruo
2016-12-09  4:36   ` Chandan Rajendra
2016-12-14 12:38   ` David Sterba
2016-12-09  1:04 ` Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).