e2fsck: quiet some harmless bitmap warnings
PATCH 1/5 e2fsck: quiet some harmless bitmap warnings
E2fsck checks block numbers against the block_metadata_map before it checks to see whether or not the block numbers are valid. So suppress these harmless warnings.
--- e2fsck/pass1.c | 2 ++ tests/f_ind_inode_collision/expect.1 | 1 - tests/f_itable_collision/expect.1 | 8 -------- 3 files changed, 2 insertions(+), 9 deletions(-)
e2fsck/pass1.c +2 -0
@@ -2710,6 +2710,7 @@ report_problem:* will reallocate the block; then we can try again. */ if (pb->ino !=EXT2_RESIZE_INO && + extent.e_pblk < ctx->fs->super->s_blocks_count &&ext2fs_test_block_bitmap2 (ctx->block_metadata_map, extent.e_pblk)) { next_try_repairs =0 ;
@@ -3448,6 +3449,7 @@ static int process_block(ext2_filsys fs,*/ if (blockcnt <0 && p->ino !=EXT2_RESIZE_INO && + blk < ctx->fs->super->s_blocks_count &&ext2fs_test_block_bitmap2 (ctx->block_metadata_map, blk)) { pctx->blk = blk;fix_problem (ctx,PR_1_CRITICAL_METADATA_COLLISION , pctx);
tests/f_ind_inode_collision/expect.1 +0 -1
@@ -2,7 +2,6 @@ Pass 1: Checking inodes, blocks, and sizes Inode 12 block 41 conflicts with critical metadata, skipping block checks. Inode 12 block 40 conflicts with critical metadata, skipping block checks. Inode 12 block 34 conflicts with critical metadata, skipping block checks. -Illegal block number passed to ext2fs_test_block_bitmap #16777215 for metadata block map Inode 12 block 1 conflicts with critical metadata, skipping block checks. Inode 12, i_size is 33, should be 25227264. Fix? yes
tests/f_itable_collision/expect.1 +0 -8
@@ -12,23 +12,15 @@ Inodes that were part of a corrupted orphan linked list found. Fix? yes Inode 49 was part of the orphaned inode list. FIXED. Inode 14 block 36 conflicts with critical metadata, skipping block checks. -Illegal block number passed to ext2fs_test_block_bitmap #4294967295 for metadata block map Inode 14 has illegal block(s). Clear? yes Illegal indirect block (4294967295) in inode 14. CLEARED. -Illegal block number passed to ext2fs_test_block_bitmap #4294967295 for metadata block map Illegal indirect block (4294967295) in inode 14. CLEARED. -Illegal block number passed to ext2fs_test_block_bitmap #4294967295 for metadata block map Illegal indirect block (4294967295) in inode 14. CLEARED. -Illegal block number passed to ext2fs_test_block_bitmap #4294967295 for metadata block map Illegal indirect block (4294967295) in inode 14. CLEARED. -Illegal block number passed to ext2fs_test_block_bitmap #4294967295 for metadata block map Illegal indirect block (4294967295) in inode 14. CLEARED. -Illegal block number passed to ext2fs_test_block_bitmap #4294967295 for metadata block map Illegal indirect block (4294967295) in inode 14. CLEARED. -Illegal block number passed to ext2fs_test_block_bitmap #4294967295 for metadata block map Illegal indirect block (4294967295) in inode 14. CLEARED. -Illegal block number passed to ext2fs_test_block_bitmap #4294967295 for metadata block map Too many illegal blocks in inode 14. Clear inode? yes
Signature · 1 line
2.11.0.rc0.7.gbe5a750
PATCH 2/5 e2fsck: don't restart after a critical metadata collision in e2fsck -n mode
If the file system isn't going to be changed, there's no point restarting; it will just cause e2fsck to loop forever.
This problem was found using American Fuzzy Lop.
--- e2fsck/pass1.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
e2fsck/pass1.c +4 -2
@@ -2718,7 +2718,8 @@ report_problem:fix_problem (ctx,PR_1_CRITICAL_METADATA_COLLISION , pctx); - ctx->flags |=E2F_FLAG_RESTART_LATER ; +if ((ctx->options &E2F_OPT_NO ) ==0 ) + ctx->flags |=E2F_FLAG_RESTART_LATER ; } pctx->errcode =ext2fs_extent_get (ehandle,EXT2_EXTENT_DOWN , &extent);
@@ -3453,7 +3454,8 @@ static int process_block(ext2_filsys fs, ext2fs_test_block_bitmap2(ctx->block_metadata_map, blk)) { pctx->blk = blk;fix_problem (ctx,PR_1_CRITICAL_METADATA_COLLISION , pctx); - ctx->flags |=E2F_FLAG_RESTART_LATER ; +if ((ctx->options &E2F_OPT_NO ) ==0 ) + ctx->flags |=E2F_FLAG_RESTART_LATER ; }if (problem) {
Signature · 1 line
2.11.0.rc0.7.gbe5a750
PATCH 3/5 libext2fs: add stricter checks on the inode size in ext2fs_open2()
In reply to Theodore Ts'oAn inode size larger than the block size can cause userspace programs to crash.
This problem was found using American Fuzzy Lop.
--- lib/ext2fs/openfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
lib/ext2fs/openfs.c +5 -1
@@ -121,6 +121,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,blk64_t group_block, blk;char *dest, *cp;int group_zero_adjust =0 ; +int inode_size;#ifdef WORDS_BIGENDIAN unsigned int groups_per_block;struct ext2_group_desc *gdp;
@@ -297,7 +298,10 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, goto cleanup; } fs->fragsize = fs->blocksize =EXT2_BLOCK_SIZE (fs->super); -if (EXT2_INODE_SIZE (fs->super) <EXT2_GOOD_OLD_INODE_SIZE ) { + inode_size =EXT2_INODE_SIZE (fs->super); +if ((inode_size <EXT2_GOOD_OLD_INODE_SIZE ) || + (inode_size > fs->blocksize) || + (inode_size & (inode_size -1 ))) { retval =EXT2_ET_CORRUPT_SUPERBLOCK ; goto cleanup; }
Signature · 1 line
2.11.0.rc0.7.gbe5a750
PATCH 4/5 debugfs: add sanity checking to the string_to_inode() utility function
In reply to Theodore Ts'oOtherwise it's possible for a corrupt file system or bad user input to cause debugfs to crash if the resulting inode number is insanely large.
This problem was found using American Fuzzy Lop.
--- debugfs/util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
debugfs/util.c +6 -1
@@ -119,7 +119,7 @@ ext2_ino_t string_to_inode(char *str)*/ if ((len >2 ) && (str[0 ] =='<' ) && (str[len-1 ] =='>' )) { ino =strtoul (str+1 , &end,0 ); -if (*end=='>' ) +if (*end=='>' && (ino <= current_fs->super->s_inodes_count))return ino; }
@@ -128,6 +128,11 @@ ext2_ino_t string_to_inode(char *str)com_err (str, retval,0 );return 0 ; } +if (ino > current_fs->super->s_inodes_count) { +com_err (str,0 ,"resolves to an illegal inode number: %u\n" , + ino); +return 0 ; + }return ino; }
Signature · 1 line
2.11.0.rc0.7.gbe5a750
PATCH 5/5 resize2fs: sanity check the free blocks and inode counts
In reply to Theodore Ts'oIf the free block or free inodes count are larger than the number of blocks or inodes in the system, request that the file system be checked. Otherwise it's possible for calcuate_minimum_resize_size() to hang in an infinite loop.
This problem was found using American Fuzzy Lop.
--- resize/main.c | 4 ++++ 1 file changed, 4 insertions(+)
resize/main.c +4 -0
@@ -440,6 +440,10 @@ int main (int argc, char ** argv) !print_min_size) checkit =1 ; +if ((fs->super->s_free_blocks_count > fs->super->s_blocks_count) || + (fs->super->s_free_inodes_count > fs->super->s_inodes_count)) + checkit =1 ; +if (checkit) { fprintf(stderr, _("Please run 'e2fsck -f %s' first.\n\n"),
Signature · 1 line
2.11.0.rc0.7.gbe5a750