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