aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2022-08-06 01:37:20 -0400
committerTheodore Ts'o <tytso@mit.edu>2022-08-06 02:16:47 -0400
commit2a2b9ceb99c226952a96abbcfb95b2540f8b7ecd (patch)
treed8e69a74e160a16087d67e18bc505d5c28c20097
parent0288b1fd6909e92e3668dde8f1f6401fdabd1494 (diff)
downloade2fsprogs-2a2b9ceb99c226952a96abbcfb95b2540f8b7ecd.tar.gz
libext2fs: teach ext2fs_open() to reject file systems with an invalid cluster size
If the cluster size is smaller than the block size, this can result in a negative shift, which is undefined. When such a file system is opened, immediately return an error indicating that the file system is corrupted. Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--lib/ext2fs/openfs.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index 5ec8ed5c1..05839ad68 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -295,8 +295,11 @@ retry:
}
}
- if (fs->super->s_log_block_size >
- (unsigned) (EXT2_MAX_BLOCK_LOG_SIZE - EXT2_MIN_BLOCK_LOG_SIZE)) {
+ if ((fs->super->s_log_block_size >
+ (unsigned) (EXT2_MAX_BLOCK_LOG_SIZE - EXT2_MIN_BLOCK_LOG_SIZE)) ||
+ (fs->super->s_log_cluster_size >
+ (unsigned) (EXT2_MAX_CLUSTER_LOG_SIZE - EXT2_MIN_CLUSTER_LOG_SIZE)) ||
+ (fs->super->s_log_block_size > fs->super->s_log_cluster_size)) {
retval = EXT2_ET_CORRUPT_SUPERBLOCK;
goto cleanup;
}