|
|
393826 |
From 8a51e038d172c3405466ddb60d712c2ac934b954 Mon Sep 17 00:00:00 2001
|
|
|
393826 |
From: Theodore Ts'o <tytso@mit.edu>
|
|
|
393826 |
Date: Thu, 19 Dec 2019 19:37:34 -0500
|
|
|
393826 |
Subject: [PATCH 07/10] e2fsck: abort if there is a corrupted directory block
|
|
|
393826 |
when rehashing
|
|
|
393826 |
|
|
|
393826 |
In e2fsck pass 3a, when we are rehashing directories, at least in
|
|
|
393826 |
theory, all of the directories should have had corruptions with
|
|
|
393826 |
respect to directory entry structure fixed. However, it's possible
|
|
|
393826 |
(for example, if the user declined a fix) that we can reach this stage
|
|
|
393826 |
of processing with a corrupted directory entries.
|
|
|
393826 |
|
|
|
393826 |
So check for that case and don't try to process a corrupted directory
|
|
|
393826 |
block so we don't run into trouble in mutate_name() if there is a
|
|
|
393826 |
zero-length file name.
|
|
|
393826 |
|
|
|
393826 |
Addresses: TALOS-2019-0973
|
|
|
393826 |
Addresses: CVE-2019-5188
|
|
|
393826 |
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
|
|
393826 |
---
|
|
|
393826 |
e2fsck/rehash.c | 9 +++++++++
|
|
|
393826 |
1 file changed, 9 insertions(+)
|
|
|
393826 |
|
|
|
393826 |
diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
|
|
|
393826 |
index a5fc1be1..3dd1e941 100644
|
|
|
393826 |
--- a/e2fsck/rehash.c
|
|
|
393826 |
+++ b/e2fsck/rehash.c
|
|
|
393826 |
@@ -160,6 +160,10 @@ static int fill_dir_block(ext2_filsys fs,
|
|
|
393826 |
dir_offset += rec_len;
|
|
|
393826 |
if (dirent->inode == 0)
|
|
|
393826 |
continue;
|
|
|
393826 |
+ if ((name_len) == 0) {
|
|
|
393826 |
+ fd->err = EXT2_ET_DIR_CORRUPTED;
|
|
|
393826 |
+ return BLOCK_ABORT;
|
|
|
393826 |
+ }
|
|
|
393826 |
if (!fd->compress && (name_len == 1) &&
|
|
|
393826 |
(dirent->name[0] == '.'))
|
|
|
393826 |
continue;
|
|
|
393826 |
@@ -401,6 +405,11 @@ static int duplicate_search_and_fix(e2fsck_t ctx, ext2_filsys fs,
|
|
|
393826 |
continue;
|
|
|
393826 |
}
|
|
|
393826 |
new_len = ext2fs_dirent_name_len(ent->dir);
|
|
|
393826 |
+ if (new_len == 0) {
|
|
|
393826 |
+ /* should never happen */
|
|
|
393826 |
+ ext2fs_unmark_valid(fs);
|
|
|
393826 |
+ continue;
|
|
|
393826 |
+ }
|
|
|
393826 |
memcpy(new_name, ent->dir->name, new_len);
|
|
|
393826 |
mutate_name(new_name, &new_len);
|
|
|
393826 |
for (j=0; j < fd->num_array; j++) {
|
|
|
393826 |
--
|
|
|
393826 |
2.21.1
|
|
|
393826 |
|