Whamcloud - gitweb
libext2fs: allow file systems which have insane values in s_desc_size
authorTheodore Ts'o <tytso@mit.edu>
Wed, 13 Jun 2018 22:55:56 +0000 (18:55 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 13 Jun 2018 22:55:56 +0000 (18:55 -0400)
If the 64-bit feature is not set, the kernel does not pay attention to
the s_desc_size field in the superblock.  Change ext2fs_open2() and
other library functions to similarly ignore s_desc_size if the 64-bit
feature is not set.

The EXT2_DESC_SIZE macro should be used in most cases instead of
referecing the s_desc_size field directly.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/blknum.c
lib/ext2fs/csum.c
lib/ext2fs/openfs.c

index aa0e911..9ee5c66 100644 (file)
@@ -208,7 +208,7 @@ __u32 ext2fs_block_bitmap_checksum(ext2_filsys fs, dgrp_t group)
 
        gdp = ext4fs_group_desc(fs, fs->group_desc, group);
        csum = gdp->bg_block_bitmap_csum_lo;
-       if (fs->super->s_desc_size >= EXT4_BG_BLOCK_BITMAP_CSUM_HI_LOCATION)
+       if (EXT2_DESC_SIZE(fs->super) >= EXT4_BG_BLOCK_BITMAP_CSUM_HI_LOCATION)
                csum |= ((__u32)gdp->bg_block_bitmap_csum_hi << 16);
        return csum;
 }
@@ -249,7 +249,7 @@ __u32 ext2fs_inode_bitmap_checksum(ext2_filsys fs, dgrp_t group)
 
        gdp = ext4fs_group_desc(fs, fs->group_desc, group);
        csum = gdp->bg_inode_bitmap_csum_lo;
-       if (fs->super->s_desc_size >= EXT4_BG_INODE_BITMAP_CSUM_HI_END)
+       if (EXT2_DESC_SIZE(fs->super) >= EXT4_BG_INODE_BITMAP_CSUM_HI_END)
                csum |= ((__u32)gdp->bg_inode_bitmap_csum_hi << 16);
        return csum;
 }
index 66c41c8..9823613 100644 (file)
@@ -563,7 +563,7 @@ int ext2fs_inode_bitmap_csum_verify(ext2_filsys fs, dgrp_t group,
        provided = gdp->bg_inode_bitmap_csum_lo;
        calculated = ext2fs_crc32c_le(fs->csum_seed, (unsigned char *)bitmap,
                                      size);
-       if (fs->super->s_desc_size >= EXT4_BG_INODE_BITMAP_CSUM_HI_END)
+       if (EXT2_DESC_SIZE(fs->super) >= EXT4_BG_INODE_BITMAP_CSUM_HI_END)
                provided |= (__u32)gdp->bg_inode_bitmap_csum_hi << 16;
        else
                calculated &= 0xFFFF;
@@ -583,7 +583,7 @@ errcode_t ext2fs_inode_bitmap_csum_set(ext2_filsys fs, dgrp_t group,
 
        crc = ext2fs_crc32c_le(fs->csum_seed, (unsigned char *)bitmap, size);
        gdp->bg_inode_bitmap_csum_lo = crc & 0xFFFF;
-       if (fs->super->s_desc_size >= EXT4_BG_INODE_BITMAP_CSUM_HI_END)
+       if (EXT2_DESC_SIZE(fs->super) >= EXT4_BG_INODE_BITMAP_CSUM_HI_END)
                gdp->bg_inode_bitmap_csum_hi = crc >> 16;
 
        return 0;
@@ -601,7 +601,7 @@ int ext2fs_block_bitmap_csum_verify(ext2_filsys fs, dgrp_t group,
        provided = gdp->bg_block_bitmap_csum_lo;
        calculated = ext2fs_crc32c_le(fs->csum_seed, (unsigned char *)bitmap,
                                      size);
-       if (fs->super->s_desc_size >= EXT4_BG_BLOCK_BITMAP_CSUM_HI_LOCATION)
+       if (EXT2_DESC_SIZE(fs->super) >= EXT4_BG_BLOCK_BITMAP_CSUM_HI_LOCATION)
                provided |= (__u32)gdp->bg_block_bitmap_csum_hi << 16;
        else
                calculated &= 0xFFFF;
@@ -621,7 +621,7 @@ errcode_t ext2fs_block_bitmap_csum_set(ext2_filsys fs, dgrp_t group,
 
        crc = ext2fs_crc32c_le(fs->csum_seed, (unsigned char *)bitmap, size);
        gdp->bg_block_bitmap_csum_lo = crc & 0xFFFF;
-       if (fs->super->s_desc_size >= EXT4_BG_BLOCK_BITMAP_CSUM_HI_LOCATION)
+       if (EXT2_DESC_SIZE(fs->super) >= EXT4_BG_BLOCK_BITMAP_CSUM_HI_LOCATION)
                gdp->bg_block_bitmap_csum_hi = crc >> 16;
 
        return 0;
index 532e70f..2172957 100644 (file)
@@ -319,12 +319,6 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
                        retval = EXT2_ET_BAD_DESC_SIZE;
                        goto cleanup;
                }
-       } else {
-               if (fs->super->s_desc_size &&
-                   fs->super->s_desc_size != EXT2_MIN_DESC_SIZE) {
-                       retval = EXT2_ET_BAD_DESC_SIZE;
-                       goto cleanup;
-               }
        }
 
        fs->cluster_ratio_bits = fs->super->s_log_cluster_size -