From 6220b6715f4900bbcfa04ef3b81ccf48b2d21825 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 4 Jun 2011 16:36:19 -0400 Subject: [PATCH] libext2fs: require cluster size == block_size when opening a !bigalloc fs In ext2fs_open() check to make sure the cluster size superblock field is the same as the block size field when the bigalloc feature is not set. This is necessary since we will start introducing calculations based on the cluster size field. Signed-off-by: "Theodore Ts'o" --- lib/ext2fs/openfs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c index a20b923a..f87c1717 100644 --- a/lib/ext2fs/openfs.c +++ b/lib/ext2fs/openfs.c @@ -239,6 +239,12 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, retval = EXT2_ET_CORRUPT_SUPERBLOCK; goto cleanup; } + if (!EXT2_HAS_RO_COMPAT_FEATURE(fs->super, + EXT4_FEATURE_RO_COMPAT_BIGALLOC) && + (fs->super->s_log_block_size != fs->super->s_log_cluster_size)) { + retval = EXT2_ET_CORRUPT_SUPERBLOCK; + goto cleanup; + } fs->blocksize = EXT2_BLOCK_SIZE(fs->super); if (EXT2_INODE_SIZE(fs->super) < EXT2_GOOD_OLD_INODE_SIZE) { retval = EXT2_ET_CORRUPT_SUPERBLOCK;