If s_log_groups_per_flex is greater than 31, it will result in an
UBSAN error, since it will result in an invalid shift exponent when
calculating the flex_bg size. So reject such file systems when they
are opened. (The mke2fs program will not allow the creation of such
file systems, so they can only occur due to corruption.)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
(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)) {
+ (fs->super->s_log_block_size > fs->super->s_log_cluster_size) ||
+ (fs->super->s_log_groups_per_flex > 31)) {
retval = EXT2_ET_CORRUPT_SUPERBLOCK;
goto cleanup;
}