ext4: verify s_clusters_per_group even without bigalloc
authorJan Kara <jack@suse.cz>
Mon, 19 Feb 2024 17:10:33 +0000 (18:10 +0100)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 7 Mar 2024 18:32:54 +0000 (13:32 -0500)
commit40da553f5da020931e9cddf02948847a188c5223
treee6237af6ed5878dce9a8e8ad2e3ecc272b1c1e83
parenta6b3bfe176e8a5b05ec4447404e412c2a3fc92cc
ext4: verify s_clusters_per_group even without bigalloc

Currently we ignore s_clusters_per_group field in the on-disk superblock
if bigalloc feature is not enabled. However e2fsprogs don't even open
the filesystem if s_clusters_per_group is invalid. This results in an
odd state where kernel happily works with the filesystem while even
e2fsck refuses to touch it. Verify that s_clusters_per_group is valid
even if bigalloc feature is not enabled to make things consistent. Due
to current e2fsprogs behavior it is unlikely there are filesystems out
in the wild (except for intentionally fuzzed ones) with invalid
s_clusters_per_group counts.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Link: https://lore.kernel.org/r/20240219171033.22882-1-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/super.c