Skip to content

Commit 0f2ddca

Browse files
From: Thiemo Nageltytso
authored andcommitted
ext4: check block device size on mount
Signed-off-by: Thiemo Nagel <thiemo.nagel@ph.tum.de> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent e44543b commit 0f2ddca

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

fs/ext4/super.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,6 +2508,15 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
25082508
if (EXT4_BLOCKS_PER_GROUP(sb) == 0)
25092509
goto cantfind_ext4;
25102510

2511+
/* check blocks count against device size */
2512+
blocks_count = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits;
2513+
if (blocks_count && ext4_blocks_count(es) > blocks_count) {
2514+
printk(KERN_WARNING "EXT4-fs: bad geometry: block count %llu "
2515+
"exceeds size of device (%llu blocks)\n",
2516+
ext4_blocks_count(es), blocks_count);
2517+
goto failed_mount;
2518+
}
2519+
25112520
/*
25122521
* It makes no sense for the first data block to be beyond the end
25132522
* of the filesystem.

0 commit comments

Comments
 (0)