diff options
author | Andreas Wellving <andreas.wellving@enea.com> | 2019-05-22 09:50:32 +0200 |
---|---|---|
committer | Adrian Mangeac <Adrian.Mangeac@enea.com> | 2019-05-22 11:50:40 +0200 |
commit | fcd9aedd7bace7481289edecdf7cc1a9c74e2924 (patch) | |
tree | 8c3b5957cc10f9a720f2809468e8d35a7c40f190 | |
parent | 8649d61b3a68a499bcd21500b08069d54226cc80 (diff) | |
download | enea-kernel-cache-fcd9aedd7bace7481289edecdf7cc1a9c74e2924.tar.gz |
ext4: CVE-2018-10840
ext4: correctly handle a zero-length xattr with a non-zero e_value_offs
Reference:
https://nvd.nist.gov/vuln/detail/CVE-2018-10840
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.14.y&id=21542545990c5aba4b919ac0f8c8ae6a408b49d4
Change-Id: I674565e08afe9331e553847a3d22ad2dda86be57
Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
-rw-r--r-- | patches/cve/CVE-2018-10840-ext4-correctly-handle-a-zero-length-xattr-with-a-non.patch | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/patches/cve/CVE-2018-10840-ext4-correctly-handle-a-zero-length-xattr-with-a-non.patch b/patches/cve/CVE-2018-10840-ext4-correctly-handle-a-zero-length-xattr-with-a-non.patch new file mode 100644 index 0000000..8a11f48 --- /dev/null +++ b/patches/cve/CVE-2018-10840-ext4-correctly-handle-a-zero-length-xattr-with-a-non.patch | |||
@@ -0,0 +1,76 @@ | |||
1 | From 21542545990c5aba4b919ac0f8c8ae6a408b49d4 Mon Sep 17 00:00:00 2001 | ||
2 | From: Theodore Ts'o <tytso@mit.edu> | ||
3 | Date: Wed, 23 May 2018 11:31:03 -0400 | ||
4 | Subject: [PATCH] ext4: correctly handle a zero-length xattr with a non-zero | ||
5 | e_value_offs | ||
6 | |||
7 | commit 8a2b307c21d4b290e3cbe33f768f194286d07c23 upstream. | ||
8 | |||
9 | Ext4 will always create ext4 extended attributes which do not have a | ||
10 | value (where e_value_size is zero) with e_value_offs set to zero. In | ||
11 | most places e_value_offs will not be used in a substantive way if | ||
12 | e_value_size is zero. | ||
13 | |||
14 | There was one exception to this, which is in ext4_xattr_set_entry(), | ||
15 | where if there is a maliciously crafted file system where there is an | ||
16 | extended attribute with e_value_offs is non-zero and e_value_size is | ||
17 | 0, the attempt to remove this xattr will result in a negative value | ||
18 | getting passed to memmove, leading to the following sadness: | ||
19 | |||
20 | [ 41.225365] EXT4-fs (loop0): mounted filesystem with ordered data mode. Opts: (null) | ||
21 | [ 44.538641] BUG: unable to handle kernel paging request at ffff9ec9a3000000 | ||
22 | [ 44.538733] IP: __memmove+0x81/0x1a0 | ||
23 | [ 44.538755] PGD 1249bd067 P4D 1249bd067 PUD 1249c1067 PMD 80000001230000e1 | ||
24 | [ 44.538793] Oops: 0003 [#1] SMP PTI | ||
25 | [ 44.539074] CPU: 0 PID: 1470 Comm: poc Not tainted 4.16.0-rc1+ #1 | ||
26 | ... | ||
27 | [ 44.539475] Call Trace: | ||
28 | [ 44.539832] ext4_xattr_set_entry+0x9e7/0xf80 | ||
29 | ... | ||
30 | [ 44.539972] ext4_xattr_block_set+0x212/0xea0 | ||
31 | ... | ||
32 | [ 44.540041] ext4_xattr_set_handle+0x514/0x610 | ||
33 | [ 44.540065] ext4_xattr_set+0x7f/0x120 | ||
34 | [ 44.540090] __vfs_removexattr+0x4d/0x60 | ||
35 | [ 44.540112] vfs_removexattr+0x75/0xe0 | ||
36 | [ 44.540132] removexattr+0x4d/0x80 | ||
37 | ... | ||
38 | [ 44.540279] path_removexattr+0x91/0xb0 | ||
39 | [ 44.540300] SyS_removexattr+0xf/0x20 | ||
40 | [ 44.540322] do_syscall_64+0x71/0x120 | ||
41 | [ 44.540344] entry_SYSCALL_64_after_hwframe+0x21/0x86 | ||
42 | |||
43 | https://bugzilla.kernel.org/show_bug.cgi?id=199347 | ||
44 | |||
45 | This addresses CVE-2018-10840. | ||
46 | |||
47 | CVE: CVE-2018-10840 | ||
48 | Upstream-Status: Backport [https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.14.y&id=21542545990c5aba4b919ac0f8c8ae6a408b49d4] | ||
49 | |||
50 | Reported-by: "Xu, Wen" <wen.xu@gatech.edu> | ||
51 | Signed-off-by: Theodore Ts'o <tytso@mit.edu> | ||
52 | Reviewed-by: Andreas Dilger <adilger@dilger.ca> | ||
53 | Cc: stable@kernel.org | ||
54 | Fixes: dec214d00e0d7 ("ext4: xattr inode deduplication") | ||
55 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||
56 | Signed-off-by: Andreas Wellving <andreas.wellving@enea.com> | ||
57 | --- | ||
58 | fs/ext4/xattr.c | 2 +- | ||
59 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
60 | |||
61 | diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c | ||
62 | index 1718354e6322..ed1cf24a7831 100644 | ||
63 | --- a/fs/ext4/xattr.c | ||
64 | +++ b/fs/ext4/xattr.c | ||
65 | @@ -1687,7 +1687,7 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i, | ||
66 | |||
67 | /* No failures allowed past this point. */ | ||
68 | |||
69 | - if (!s->not_found && here->e_value_offs) { | ||
70 | + if (!s->not_found && here->e_value_size && here->e_value_offs) { | ||
71 | /* Remove the old value. */ | ||
72 | void *first_val = s->base + min_offs; | ||
73 | size_t offs = le16_to_cpu(here->e_value_offs); | ||
74 | -- | ||
75 | 2.20.1 | ||
76 | |||