diff options
author | Theodore Ts'o <tytso@mit.edu> | 2016-11-18 13:28:30 -0500 |
---|---|---|
committer | Sasha Levin <alexander.levin@verizon.com> | 2017-01-12 20:56:53 -0500 |
commit | 31eb998aa42dd8fa96bea51320f21eb005ad752d (patch) | |
tree | 6168e88972fdc03f10e8f7297847b8f565233101 /fs | |
parent | 526cfedac0b3e2a4fd19bd43f34be2a52e002234 (diff) |
ext4: use more strict checks for inodes_per_block on mount
[ Upstream commit cd6bb35bf7f6d7d922509bf50265383a0ceabe96 ]
Centralize the checks for inodes_per_block and be more strict to make
sure the inodes_per_block_group can't end up being zero.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/super.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 04e6abf707f7..c34e6a93854b 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -3840,12 +3840,16 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group); sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group); - if (EXT4_INODE_SIZE(sb) == 0 || EXT4_INODES_PER_GROUP(sb) == 0) - goto cantfind_ext4; sbi->s_inodes_per_block = blocksize / EXT4_INODE_SIZE(sb); if (sbi->s_inodes_per_block == 0) goto cantfind_ext4; + if (sbi->s_inodes_per_group < sbi->s_inodes_per_block || + sbi->s_inodes_per_group > blocksize * 8) { + ext4_msg(sb, KERN_ERR, "invalid inodes per group: %lu\n", + sbi->s_blocks_per_group); + goto failed_mount; + } sbi->s_itb_per_group = sbi->s_inodes_per_group / sbi->s_inodes_per_block; sbi->s_desc_per_block = blocksize / EXT4_DESC_SIZE(sb); @@ -3929,13 +3933,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) } sbi->s_cluster_ratio = clustersize / blocksize; - if (sbi->s_inodes_per_group > blocksize * 8) { - ext4_msg(sb, KERN_ERR, - "#inodes per group too big: %lu", - sbi->s_inodes_per_group); - goto failed_mount; - } - /* Do we have standard group size of clustersize * 8 blocks ? */ if (sbi->s_blocks_per_group == clustersize << 3) set_opt2(sb, STD_GROUP_SIZE); |