@@ -4718,6 +4718,25 @@ static int ext4_check_geometry(struct super_block *sb,
47184718{
47194719 struct ext4_sb_info * sbi = EXT4_SB (sb );
47204720 __u64 blocks_count ;
4721+ int err ;
4722+
4723+ if (le16_to_cpu (sbi -> s_es -> s_reserved_gdt_blocks ) > (sb -> s_blocksize / 4 )) {
4724+ ext4_msg (sb , KERN_ERR ,
4725+ "Number of reserved GDT blocks insanely large: %d" ,
4726+ le16_to_cpu (sbi -> s_es -> s_reserved_gdt_blocks ));
4727+ return - EINVAL ;
4728+ }
4729+ /*
4730+ * Test whether we have more sectors than will fit in sector_t,
4731+ * and whether the max offset is addressable by the page cache.
4732+ */
4733+ err = generic_check_addressable (sb -> s_blocksize_bits ,
4734+ ext4_blocks_count (es ));
4735+ if (err ) {
4736+ ext4_msg (sb , KERN_ERR , "filesystem"
4737+ " too large to mount safely on this system" );
4738+ return err ;
4739+ }
47214740
47224741 /* check blocks count against device size */
47234742 blocks_count = sb_bdev_nr_blocks (sb );
@@ -5174,13 +5193,6 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
51745193 if (ext4_check_feature_compatibility (sb , es , silent ))
51755194 goto failed_mount ;
51765195
5177- if (le16_to_cpu (sbi -> s_es -> s_reserved_gdt_blocks ) > (sb -> s_blocksize / 4 )) {
5178- ext4_msg (sb , KERN_ERR ,
5179- "Number of reserved GDT blocks insanely large: %d" ,
5180- le16_to_cpu (sbi -> s_es -> s_reserved_gdt_blocks ));
5181- goto failed_mount ;
5182- }
5183-
51845196 if (sbi -> s_daxdev ) {
51855197 if (sb -> s_blocksize == PAGE_SIZE )
51865198 set_bit (EXT4_FLAGS_BDEV_IS_DAX , & sbi -> s_ext4_flags );
@@ -5252,18 +5264,6 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
52525264 if (ext4_handle_clustersize (sb ))
52535265 goto failed_mount ;
52545266
5255- /*
5256- * Test whether we have more sectors than will fit in sector_t,
5257- * and whether the max offset is addressable by the page cache.
5258- */
5259- err = generic_check_addressable (sb -> s_blocksize_bits ,
5260- ext4_blocks_count (es ));
5261- if (err ) {
5262- ext4_msg (sb , KERN_ERR , "filesystem"
5263- " too large to mount safely on this system" );
5264- goto failed_mount ;
5265- }
5266-
52675267 if (ext4_check_geometry (sb , es ))
52685268 goto failed_mount ;
52695269
0 commit comments