Whamcloud - gitweb
libext2fs: in ext2fs_open[2](), return an error if s_first_meta_bg is too big
authorTheodore Ts'o <tytso@mit.edu>
Tue, 13 Sep 2022 11:59:52 +0000 (07:59 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 13 Sep 2022 11:59:52 +0000 (07:59 -0400)
These checks will be skipped for e2fsck when it uses the flag
EXT2_FLAG_IGNORE_SB_ERRORS.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/openfs.c
tests/f_first_meta_bg_too_big/expect.1

index 39229d7..fea352f 100644 (file)
@@ -409,6 +409,12 @@ retry:
        }
        fs->desc_blocks = ext2fs_div_ceil(fs->group_desc_count,
                                          EXT2_DESC_PER_BLOCK(fs->super));
+       if (ext2fs_has_feature_meta_bg(fs->super) &&
+           (fs->super->s_first_meta_bg > fs->desc_blocks) &&
+           !(flags & EXT2_FLAG_IGNORE_SB_ERRORS)) {
+               retval = EXT2_ET_CORRUPT_SUPERBLOCK;
+               goto cleanup;
+       }
        if (flags & EXT2_FLAG_SUPER_ONLY)
                goto skip_read_bg;
        retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize,
index 85786bd..3148513 100644 (file)
@@ -1,3 +1,7 @@
+ext2fs_open2: The ext2 superblock is corrupt
+../e2fsck/e2fsck: Superblock invalid, trying backup blocks...
+../e2fsck/e2fsck: The ext2 superblock is corrupt while trying to open test.img
+../e2fsck/e2fsck: Trying to load superblock despite errors...
 First_meta_bg is too big.  (2, max value 1).  Clear? yes
 
 Pass 1: Checking inodes, blocks, and sizes