Skip to content

Commit 4f2f76f

Browse files
jankaratytso
authored andcommitted
ext4: fix fencepost error in check for inode count overflow during resize
ext4_resize_fs() has an off-by-one bug when checking whether growing of a filesystem will not overflow inode count. As a result it allows a filesystem with 8192 inodes per group to grow to 64TB which overflows inode count to 0 and makes filesystem unusable. Fix it. Cc: [email protected] Fixes: 3f8a641 Reported-by: Jaco Kroon <[email protected]> Signed-off-by: Jan Kara <[email protected]> Signed-off-by: Theodore Ts'o <[email protected]> Reviewed-by: Andreas Dilger <[email protected]>
1 parent 8a2b307 commit 4f2f76f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/ext4/resize.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,7 @@ int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count)
19331933
return 0;
19341934

19351935
n_group = ext4_get_group_number(sb, n_blocks_count - 1);
1936-
if (n_group > (0xFFFFFFFFUL / EXT4_INODES_PER_GROUP(sb))) {
1936+
if (n_group >= (0xFFFFFFFFUL / EXT4_INODES_PER_GROUP(sb))) {
19371937
ext4_warning(sb, "resize would cause inodes_count overflow");
19381938
return -EINVAL;
19391939
}

0 commit comments

Comments
 (0)