aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Rosenberg <drosen@google.com>2020-06-24 22:31:16 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-06-24 22:31:16 +0000
commitc5d2af2e669543f57b69602a5fe1c744908c34a9 (patch)
treee6ea20d3de540ac124c5f81a69b11792a3109450
parent65ba12294cef761305e58c2ddab8547cb9257ee6 (diff)
parent0c0b65bdccd6b70d87d0532fe5539f037610cf03 (diff)
downloade2fsprogs-c5d2af2e669543f57b69602a5fe1c744908c34a9.tar.gz
ANDROID: e2fsck: Do not mutate encrypted names am: 0c0b65bdcc
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/e2fsprogs/+/11850659 Change-Id: I21a49904141f9d8851a45819a9268cb5f3a37a4b
-rw-r--r--e2fsck/problem.c5
-rw-r--r--e2fsck/problem.h3
-rw-r--r--e2fsck/rehash.c9
-rw-r--r--tests/f_dup_de_crypt/expect.118
-rw-r--r--tests/f_dup_de_crypt/expect.27
-rw-r--r--tests/f_dup_de_crypt/image.gzbin0 -> 3039 bytes
-rw-r--r--tests/f_dup_de_crypt/name1
7 files changed, 43 insertions, 0 deletions
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index 5eb5973d..ea9b2969 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -1779,6 +1779,11 @@ static struct e2fsck_problem problem_table[] = {
N_("Encrypted @E is too short.\n"),
PROMPT_CLEAR, 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 --git a/e2fsck/problem.h b/e2fsck/problem.h
index 5cc89249..7bcecfab 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -1017,6 +1017,9 @@ struct problem_context {
/* Encrypted directory entry is too short */
#define PR_2_BAD_ENCRYPTED_NAME 0x020050
+/* Non-unique filename found, but can't rename */
+#define PR_2_NON_UNIQUE_FILE_NO_RENAME 0x020053
+
/*
* Pass 3 errors
*/
diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
index a5fc1be1..81d67c68 100644
--- a/e2fsck/rehash.c
+++ b/e2fsck/rehash.c
@@ -400,6 +400,15 @@ static int duplicate_search_and_fix(e2fsck_t ctx, ext2_filsys fs,
fixed++;
continue;
}
+ /* Can't alter encrypted name without key, so just drop it */
+ if (fd->inode->i_flags & EXT4_ENCRYPT_FL) {
+ if (fix_problem(ctx, PR_2_NON_UNIQUE_FILE_NO_RENAME, &pctx)) {
+ e2fsck_adjust_inode_count(ctx, ent->dir->inode, -1);
+ ent->dir->inode = 0;
+ fixed++;
+ continue;
+ }
+ }
new_len = ext2fs_dirent_name_len(ent->dir);
memcpy(new_name, ent->dir->name, new_len);
mutate_name(new_name, &new_len);
diff --git a/tests/f_dup_de_crypt/expect.1 b/tests/f_dup_de_crypt/expect.1
new file mode 100644
index 00000000..03e0ad6c
--- /dev/null
+++ b/tests/f_dup_de_crypt/expect.1
@@ -0,0 +1,18 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Duplicate entry '+M-^AT^EM-1M-^CM-/)*M-L^RM-^L^@M-WM-)M-+' found.
+ Marking /test (12) to be rebuilt.
+
+Pass 3: Checking directory connectivity
+Pass 3A: Optimizing directories
+Duplicate filename entry '+M-^AT^EM-1M-^CM-/)*M-L^RM-^L^@M-WM-)M-+' in /test (12) found. Clear? yes
+
+Pass 4: Checking reference counts
+Unattached inode 13
+Connect to /lost+found? yes
+
+Pass 5: Checking group summary information
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 14/16 files (0.0% non-contiguous), 26/60 blocks
+Exit status is 1
diff --git a/tests/f_dup_de_crypt/expect.2 b/tests/f_dup_de_crypt/expect.2
new file mode 100644
index 00000000..cfca772d
--- /dev/null
+++ b/tests/f_dup_de_crypt/expect.2
@@ -0,0 +1,7 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 14/16 files (0.0% non-contiguous), 26/60 blocks
+Exit status is 0
diff --git a/tests/f_dup_de_crypt/image.gz b/tests/f_dup_de_crypt/image.gz
new file mode 100644
index 00000000..07a44d7c
--- /dev/null
+++ b/tests/f_dup_de_crypt/image.gz
Binary files differ
diff --git a/tests/f_dup_de_crypt/name b/tests/f_dup_de_crypt/name
new file mode 100644
index 00000000..aff30a8f
--- /dev/null
+++ b/tests/f_dup_de_crypt/name
@@ -0,0 +1 @@
+duplicate directory entries for encrypted dirs