summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--patches/cve/CVE-2018-10882-ext4-add-more-inode-number-paranoia-checks.patch79
1 files changed, 79 insertions, 0 deletions
diff --git a/patches/cve/CVE-2018-10882-ext4-add-more-inode-number-paranoia-checks.patch b/patches/cve/CVE-2018-10882-ext4-add-more-inode-number-paranoia-checks.patch
new file mode 100644
index 0000000..c69fd36
--- /dev/null
+++ b/patches/cve/CVE-2018-10882-ext4-add-more-inode-number-paranoia-checks.patch
@@ -0,0 +1,79 @@
1From c24aab6d86640ccf321b87be6096319f55b16274 Mon Sep 17 00:00:00 2001
2From: Theodore Ts'o <tytso@mit.edu>
3Date: Sun, 17 Jun 2018 00:41:14 -0400
4Subject: [PATCH] ext4: add more inode number paranoia checks
5
6commit c37e9e013469521d9adb932d17a1795c139b36db upstream.
7
8If there is a directory entry pointing to a system inode (such as a
9journal inode), complain and declare the file system to be corrupted.
10
11Also, if the superblock's first inode number field is too small,
12refuse to mount the file system.
13
14This addresses CVE-2018-10882.
15
16https://bugzilla.kernel.org/show_bug.cgi?id=200069
17
18CVE: CVE-2018-10882
19Upstream-Status: Backport [https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.14.y&id=c24aab6d86640ccf321b87be6096319f55b16274]
20
21Signed-off-by: Theodore Ts'o <tytso@mit.edu>
22Cc: stable@kernel.org
23Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
25---
26 fs/ext4/ext4.h | 5 -----
27 fs/ext4/inode.c | 3 ++-
28 fs/ext4/super.c | 5 +++++
29 3 files changed, 7 insertions(+), 6 deletions(-)
30
31diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
32index db389611f8bc..0abb30d19fa1 100644
33--- a/fs/ext4/ext4.h
34+++ b/fs/ext4/ext4.h
35@@ -1542,11 +1542,6 @@ static inline struct ext4_inode_info *EXT4_I(struct inode *inode)
36 static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
37 {
38 return ino == EXT4_ROOT_INO ||
39- ino == EXT4_USR_QUOTA_INO ||
40- ino == EXT4_GRP_QUOTA_INO ||
41- ino == EXT4_BOOT_LOADER_INO ||
42- ino == EXT4_JOURNAL_INO ||
43- ino == EXT4_RESIZE_INO ||
44 (ino >= EXT4_FIRST_INO(sb) &&
45 ino <= le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count));
46 }
47diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
48index 5b28153eb0fd..c2efe4d2ad87 100644
49--- a/fs/ext4/inode.c
50+++ b/fs/ext4/inode.c
51@@ -4455,7 +4455,8 @@ static int __ext4_get_inode_loc(struct inode *inode,
52 int inodes_per_block, inode_offset;
53
54 iloc->bh = NULL;
55- if (!ext4_valid_inum(sb, inode->i_ino))
56+ if (inode->i_ino < EXT4_ROOT_INO ||
57+ inode->i_ino > le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count))
58 return -EFSCORRUPTED;
59
60 iloc->block_group = (inode->i_ino - 1) / EXT4_INODES_PER_GROUP(sb);
61diff --git a/fs/ext4/super.c b/fs/ext4/super.c
62index fefcfa9fe408..6933efbb582f 100644
63--- a/fs/ext4/super.c
64+++ b/fs/ext4/super.c
65@@ -3811,6 +3811,11 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
66 } else {
67 sbi->s_inode_size = le16_to_cpu(es->s_inode_size);
68 sbi->s_first_ino = le32_to_cpu(es->s_first_ino);
69+ if (sbi->s_first_ino < EXT4_GOOD_OLD_FIRST_INO) {
70+ ext4_msg(sb, KERN_ERR, "invalid first ino: %u",
71+ sbi->s_first_ino);
72+ goto failed_mount;
73+ }
74 if ((sbi->s_inode_size < EXT4_GOOD_OLD_INODE_SIZE) ||
75 (!is_power_of_2(sbi->s_inode_size)) ||
76 (sbi->s_inode_size > blocksize)) {
77--
782.20.1
79