From 71ba13755337e19c9a826dfc874562a36e1b24d3 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 19 Dec 2019 19:45:06 -0500 Subject: [PATCH] e2fsck: don't try to rehash a deleted directory References: bsc#1160571 CVE-2019-5188 If directory has been deleted in pass1[bcd] processing, then we shouldn't try to rehash the directory in pass 3a when we try to rehash/reoptimize directories. Signed-off-by: Theodore Ts'o Acked-by: Jan Kara --- e2fsck/pass1b.c | 4 ++++ e2fsck/rehash.c | 2 ++ 2 files changed, 6 insertions(+) Index: e2fsprogs-1.42.11/e2fsck/pass1b.c =================================================================== --- e2fsprogs-1.42.11.orig/e2fsck/pass1b.c +++ e2fsprogs-1.42.11/e2fsck/pass1b.c @@ -643,6 +643,10 @@ static void delete_file(e2fsck_t ctx, ex fix_problem(ctx, PR_1B_BLOCK_ITERATE, &pctx); if (ctx->inode_bad_map) ext2fs_unmark_inode_bitmap2(ctx->inode_bad_map, ino); + if (ctx->inode_reg_map) + ext2fs_unmark_inode_bitmap2(ctx->inode_reg_map, ino); + ext2fs_unmark_inode_bitmap2(ctx->inode_dir_map, ino); + ext2fs_unmark_inode_bitmap2(ctx->inode_used_map, ino); ext2fs_inode_alloc_stats2(fs, ino, -1, LINUX_S_ISDIR(dp->inode.i_mode)); quota_data_sub(ctx->qctx, &dp->inode, ino, pb.dup_blocks * fs->blocksize); Index: e2fsprogs-1.42.11/e2fsck/rehash.c =================================================================== --- e2fsprogs-1.42.11.orig/e2fsck/rehash.c +++ e2fsprogs-1.42.11/e2fsck/rehash.c @@ -882,6 +882,8 @@ void e2fsck_rehash_directories(e2fsck_t } if (ino == ctx->lost_and_found) continue; + if (!ext2fs_test_inode_bitmap2(ctx->inode_dir_map, ino)) + continue; pctx.dir = ino; if (first) { fix_problem(ctx, PR_3A_PASS_HEADER, &pctx);