From: Theodore Ts'o Date: Thu, 28 Jan 2021 05:52:22 +0000 (-0500) Subject: Merge branch 'maint' into next X-Git-Tag: v1.46.0~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6be3ce7a545d3b49199e65cdde709ad51d1be502;p=thirdparty%2Fe2fsprogs.git Merge branch 'maint' into next --- 6be3ce7a545d3b49199e65cdde709ad51d1be502 diff --cc e2fsck/e2fsck.c index dc4b45e25,6bf68197d..51fc2a99a --- a/e2fsck/e2fsck.c +++ b/e2fsck/e2fsck.c @@@ -159,6 -154,14 +159,10 @@@ errcode_t e2fsck_reset_context(e2fsck_ ext2fs_free_mem(&ctx->invalid_inode_table_flag); ctx->invalid_inode_table_flag = 0; } - if (ctx->encrypted_dirs) { - ext2fs_u32_list_free(ctx->encrypted_dirs); - ctx->encrypted_dirs = 0; - } + if (ctx->casefolded_dirs) { + ext2fs_u32_list_free(ctx->casefolded_dirs); + ctx->casefolded_dirs = 0; + } if (ctx->inode_count) { ext2fs_free_icount(ctx->inode_count); ctx->inode_count = 0; diff --cc e2fsck/e2fsck.h index 0e910a92a,166cc1f6c..b5b16f049 --- a/e2fsck/e2fsck.h +++ b/e2fsck/e2fsck.h @@@ -425,6 -389,8 +425,7 @@@ struct e2fsck_struct int ext_attr_ver; profile_t profile; int blocks_per_page; - ext2_u32_list encrypted_dirs; + ext2_u32_list casefolded_dirs; /* Reserve blocks for root and l+f re-creation */ blk64_t root_repair_block, lnf_repair_block; diff --cc e2fsck/pass1.c index 6909fed58,bafbe8bf4..b866cc83f --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@@ -80,6 -78,8 +80,7 @@@ static void mark_table_blocks(e2fsck_t static void alloc_bb_map(e2fsck_t ctx); static void alloc_imagic_map(e2fsck_t ctx); static void mark_inode_bad(e2fsck_t ctx, ino_t ino); -static void add_encrypted_dir(e2fsck_t ctx, ino_t ino); + static void add_casefolded_dir(e2fsck_t ctx, ino_t ino); static void handle_fs_bad_blocks(e2fsck_t ctx); static void process_inodes(e2fsck_t ctx, char *block_buf); static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b); @@@ -1892,6 -1889,10 +1893,8 @@@ void e2fsck_pass1(e2fsck_t ctx ext2fs_mark_inode_bitmap2(ctx->inode_dir_map, ino); e2fsck_add_dir_info(ctx, ino, 0); ctx->fs_directory_count++; - if (inode->i_flags & EXT4_ENCRYPT_FL) - add_encrypted_dir(ctx, ino); + if (inode->i_flags & EXT4_CASEFOLD_FL) + add_casefolded_dir(ctx, ino); } else if (LINUX_S_ISREG (inode->i_mode)) { ext2fs_mark_inode_bitmap2(ctx->inode_reg_map, ino); ctx->fs_regular_count++; @@@ -2207,6 -2205,42 +2210,24 @@@ static void mark_inode_bad(e2fsck_t ctx ext2fs_mark_inode_bitmap2(ctx->inode_bad_map, ino); } -static void add_encrypted_dir(e2fsck_t ctx, ino_t ino) -{ - struct problem_context pctx; - - if (!ctx->encrypted_dirs) { - pctx.errcode = ext2fs_u32_list_create(&ctx->encrypted_dirs, 0); - if (pctx.errcode) - goto error; - } - pctx.errcode = ext2fs_u32_list_add(ctx->encrypted_dirs, ino); - if (pctx.errcode == 0) - return; -error: - fix_problem(ctx, PR_1_ALLOCATE_ENCRYPTED_DIRLIST, &pctx); - /* Should never get here */ - ctx->flags |= E2F_FLAG_ABORT; -} - + static void add_casefolded_dir(e2fsck_t ctx, ino_t ino) + { + struct problem_context pctx; + + if (!ctx->casefolded_dirs) { + pctx.errcode = ext2fs_u32_list_create(&ctx->casefolded_dirs, 0); + if (pctx.errcode) + goto error; + } + pctx.errcode = ext2fs_u32_list_add(ctx->casefolded_dirs, ino); + if (pctx.errcode == 0) + return; + error: + fix_problem(ctx, PR_1_ALLOCATE_CASEFOLDED_DIRLIST, &pctx); + /* Should never get here */ + ctx->flags |= E2F_FLAG_ABORT; + } + /* * This procedure will allocate the inode "bb" (badblock) map table */ diff --cc e2fsck/pass2.c index 7e961e82f,c1db3a1a5..8b7f84a7d --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@@ -289,11 -285,14 +289,15 @@@ void e2fsck_pass2(e2fsck_t ctx ext2fs_free_inode_bitmap(ctx->inode_reg_map); ctx->inode_reg_map = 0; } - if (ctx->encrypted_dirs) { - ext2fs_u32_list_free(ctx->encrypted_dirs); - ctx->encrypted_dirs = 0; + if (ctx->inode_casefold_map) { + ext2fs_free_inode_bitmap(ctx->inode_casefold_map); + ctx->inode_casefold_map = 0; } + destroy_encrypted_file_info(ctx); + if (ctx->casefolded_dirs) { + ext2fs_u32_list_free(ctx->casefolded_dirs); + ctx->casefolded_dirs = 0; + } clear_problem_context(&pctx); if (ctx->large_files) { @@@ -1038,7 -938,9 +1044,9 @@@ static int check_dir_block(ext2_filsys int is_leaf = 1; size_t inline_data_size = 0; int filetype = 0; - int encrypted = 0; + __u32 dir_encpolicy_id = NO_ENCRYPTION_POLICY; + int hash_in_dirent = 0; + int casefolded = 0; size_t max_block_size; int hash_flags = 0; static char *eop_read_dirblock = NULL; @@@ -1268,15 -1162,13 +1276,19 @@@ skip_checksum } else max_block_size = fs->blocksize - de_csum_size; - if (ctx->encrypted_dirs) - encrypted = ext2fs_u32_list_test(ctx->encrypted_dirs, ino); + dir_encpolicy_id = find_encryption_policy(ctx, ino); + + if (cf_dir) { + dict_init(&de_dict, DICTCOUNT_T_MAX, dict_de_cf_cmp); + dict_set_cmp_context(&de_dict, (void *)ctx->fs->encoding); + } else { + dict_init(&de_dict, DICTCOUNT_T_MAX, dict_de_cmp); + } + if (ctx->casefolded_dirs) + casefolded = ext2fs_u32_list_test(ctx->casefolded_dirs, ino); - hash_in_dirent = encrypted && casefolded; ++ hash_in_dirent = (casefolded && ++ (dir_encpolicy_id != NO_ENCRYPTION_POLICY)); - dict_init(&de_dict, DICTCOUNT_T_MAX, dict_de_cmp); prev = 0; do { dgrp_t group; diff --cc e2fsck/problem.c index 995223429,da261fcea..fe3b06a6d --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@@ -1259,16 -1253,16 +1259,27 @@@ static struct e2fsck_problem problem_ta N_("@d %p has the casefold flag, but the\ncasefold feature is not enabled. "), PROMPT_CLEAR_FLAG, 0, 0, 0, 0 }, + /* Inode has encrypt flag but no encryption extended attribute */ + { PR_1_MISSING_ENCRYPTION_XATTR, + N_("@i %i has encrypt flag but no encryption @a.\n"), + PROMPT_CLEAR_FLAG, 0, 0, 0, 0 }, + + /* Encrypted inode has corrupt encryption extended attribute */ + { PR_1_CORRUPT_ENCRYPTION_XATTR, + N_("Encrypted @i %i has corrupt encryption @a.\n"), + PROMPT_CLEAR_INODE, 0, 0, 0, 0 }, + + /* Htree directory should use SipHash but does not */ + { PR_1_HTREE_NEEDS_SIPHASH, + N_("@h %i uses hash version (%N), but should use SipHash (6) \n"), + PROMPT_CLEAR_HTREE, PR_PREEN_OK, 0, 0, 0 }, + + /* Htree directory uses SipHash but should not */ + { PR_1_HTREE_CANNOT_SIPHASH, + N_("@h %i uses SipHash, but should not. "), + PROMPT_CLEAR_HTREE, PR_PREEN_OK, 0, 0, 0 }, + ++ /* Pass 1b errors */ /* Pass 1B: Rescan for duplicate/bad blocks */ @@@ -1795,21 -1789,11 +1806,27 @@@ N_("Encrypted @E is too short.\n"), PROMPT_CLEAR, 0, 0, 0, 0 }, + /* Encrypted directory contains unencrypted file */ + { PR_2_UNENCRYPTED_FILE, + N_("Encrypted @E references unencrypted @i %Di.\n"), + PROMPT_CLEAR, 0, 0, 0, 0 }, + + /* Encrypted directory contains file with different encryption policy */ + { PR_2_INCONSISTENT_ENCRYPTION_POLICY, + N_("Encrypted @E references @i %Di, which has a different encryption policy.\n"), + PROMPT_CLEAR, 0, 0, 0, 0 }, + + /* Casefolded directory entry has illegal characters in its name */ + { PR_2_BAD_ENCODED_NAME, + N_("@E has illegal UTF-8 characters in its name.\n"), + PROMPT_FIX, 0, 0, 0, 0 }, + + /* Non-unique filename found, but can't rename */ + { PR_2_NON_UNIQUE_FILE_NO_RENAME, + N_("Duplicate filename @E found. "), + PROMPT_CLEAR, 0, 0, 0, 0 }, + ++ /* Pass 3 errors */ /* Pass 3: Checking directory connectivity */ diff --cc e2fsck/problem.h index e2fbb597a,5e67b17a4..922c99df3 --- a/e2fsck/problem.h +++ b/e2fsck/problem.h @@@ -701,12 -701,16 +701,22 @@@ struct problem_context /* Casefold flag set, but file system is missing the casefold feature */ #define PR_1_CASEFOLD_FEATURE 0x010089 +/* Inode has encrypt flag but no encryption extended attribute */ +#define PR_1_MISSING_ENCRYPTION_XATTR 0x01008A + +/* Encrypted inode has corrupt encryption extended attribute */ +#define PR_1_CORRUPT_ENCRYPTION_XATTR 0x01008B + + /* Error allocating memory for casefolded directory list */ + #define PR_1_ALLOCATE_CASEFOLDED_DIRLIST 0x01008C + + /* Htree directory should use SipHash but does not */ + #define PR_1_HTREE_NEEDS_SIPHASH 0x01008D + + /* Htree directory uses SipHash but should not */ + #define PR_1_HTREE_CANNOT_SIPHASH 0x01008E + + /* * Pass 1b errors */ diff --cc misc/tune2fs.c index f95996214,cdf343c86..40f517388 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@@ -101,8 -101,9 +101,9 @@@ static int rewrite_checksums static int feature_64bit; static int fsck_requested; static char *undo_file; + int enabling_casefold; -int journal_size, journal_flags; +int journal_size, journal_fc_size, journal_flags; char *journal_device; static blk64_t journal_location = ~0LL;