Whamcloud - gitweb
Merge branch 'maint' into next
authorTheodore Ts'o <tytso@mit.edu>
Thu, 28 Jan 2021 05:52:22 +0000 (00:52 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 28 Jan 2021 05:52:22 +0000 (00:52 -0500)
13 files changed:
1  2 
e2fsck/Android.bp
e2fsck/e2fsck.c
e2fsck/e2fsck.h
e2fsck/jfs_user.h
e2fsck/pass1.c
e2fsck/pass2.c
e2fsck/problem.c
e2fsck/problem.h
e2fsck/rehash.c
lib/ext2fs/ext2_fs.h
misc/mke2fs.c
misc/tune2fs.8.in
misc/tune2fs.c

Simple merge
diff --cc 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
@@@ -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;
Simple merge
diff --cc 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
@@@ -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;
@@@ -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 */
          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 */
@@@ -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 e2fsck/rehash.c
Simple merge
Simple merge
diff --cc misc/mke2fs.c
Simple merge
Simple merge
diff --cc 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;