diff options
| author | Andreas Wellving <andreas.wellving@enea.com> | 2019-05-22 12:10:28 +0200 |
|---|---|---|
| committer | Adrian Mangeac <Adrian.Mangeac@enea.com> | 2019-05-22 12:54:24 +0200 |
| commit | 59cd0ba424d3cb9a4e5ccd0af96bfec5875ac574 (patch) | |
| tree | 847cc2989f8cd005fb6f072de4d43e6b1f7a4b6e | |
| parent | 475fde15fe18086db2e036cb84d9e52c5e985168 (diff) | |
| download | enea-kernel-cache-59cd0ba424d3cb9a4e5ccd0af96bfec5875ac574.tar.gz | |
btrfs: CVE-2018-14609
btrfs: relocation: Only remove reloc rb_trees if reloc
control has been initialized
Reference:
https://nvd.nist.gov/vuln/detail/CVE-2018-14609
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.14.y&id=0cdbc3faf960de16ebe8a427feb3b0544ad983cc
Change-Id: Idca656bc56b18fc36ec9275e232cfd058c5c7ba9
Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
| -rw-r--r-- | patches/cve/CVE-2018-14609-btrfs-relocation-Only-remove-reloc-rb_trees-if-reloc.patch | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/patches/cve/CVE-2018-14609-btrfs-relocation-Only-remove-reloc-rb_trees-if-reloc.patch b/patches/cve/CVE-2018-14609-btrfs-relocation-Only-remove-reloc-rb_trees-if-reloc.patch new file mode 100644 index 0000000..5f38a2b --- /dev/null +++ b/patches/cve/CVE-2018-14609-btrfs-relocation-Only-remove-reloc-rb_trees-if-reloc.patch | |||
| @@ -0,0 +1,71 @@ | |||
| 1 | From 0cdbc3faf960de16ebe8a427feb3b0544ad983cc Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Qu Wenruo <wqu@suse.com> | ||
| 3 | Date: Tue, 3 Jul 2018 17:10:07 +0800 | ||
| 4 | Subject: [PATCH] btrfs: relocation: Only remove reloc rb_trees if reloc | ||
| 5 | control has been initialized | ||
| 6 | |||
| 7 | [ Upstream commit 389305b2aa68723c754f88d9dbd268a400e10664 ] | ||
| 8 | |||
| 9 | Invalid reloc tree can cause kernel NULL pointer dereference when btrfs | ||
| 10 | does some cleanup of the reloc roots. | ||
| 11 | |||
| 12 | It turns out that fs_info::reloc_ctl can be NULL in | ||
| 13 | btrfs_recover_relocation() as we allocate relocation control after all | ||
| 14 | reloc roots have been verified. | ||
| 15 | So when we hit: note, we haven't called set_reloc_control() thus | ||
| 16 | fs_info::reloc_ctl is still NULL. | ||
| 17 | |||
| 18 | CVE: CVE-2018-14609 | ||
| 19 | Upstream-Status: Backport [https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.14.y&id=0cdbc3faf960de16ebe8a427feb3b0544ad983cc] | ||
| 20 | |||
| 21 | Link: https://bugzilla.kernel.org/show_bug.cgi?id=199833 | ||
| 22 | Reported-by: Xu Wen <wen.xu@gatech.edu> | ||
| 23 | Signed-off-by: Qu Wenruo <wqu@suse.com> | ||
| 24 | Tested-by: Gu Jinxiang <gujx@cn.fujitsu.com> | ||
| 25 | Reviewed-by: David Sterba <dsterba@suse.com> | ||
| 26 | Signed-off-by: David Sterba <dsterba@suse.com> | ||
| 27 | Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> | ||
| 28 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||
| 29 | Signed-off-by: Andreas Wellving <andreas.wellving@enea.com> | ||
| 30 | --- | ||
| 31 | fs/btrfs/relocation.c | 23 ++++++++++++----------- | ||
| 32 | 1 file changed, 12 insertions(+), 11 deletions(-) | ||
| 33 | |||
| 34 | diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c | ||
| 35 | index 9841faef08ea..b80b03e0c5d3 100644 | ||
| 36 | --- a/fs/btrfs/relocation.c | ||
| 37 | +++ b/fs/btrfs/relocation.c | ||
| 38 | @@ -1334,18 +1334,19 @@ static void __del_reloc_root(struct btrfs_root *root) | ||
| 39 | struct mapping_node *node = NULL; | ||
| 40 | struct reloc_control *rc = fs_info->reloc_ctl; | ||
| 41 | |||
| 42 | - spin_lock(&rc->reloc_root_tree.lock); | ||
| 43 | - rb_node = tree_search(&rc->reloc_root_tree.rb_root, | ||
| 44 | - root->node->start); | ||
| 45 | - if (rb_node) { | ||
| 46 | - node = rb_entry(rb_node, struct mapping_node, rb_node); | ||
| 47 | - rb_erase(&node->rb_node, &rc->reloc_root_tree.rb_root); | ||
| 48 | + if (rc) { | ||
| 49 | + spin_lock(&rc->reloc_root_tree.lock); | ||
| 50 | + rb_node = tree_search(&rc->reloc_root_tree.rb_root, | ||
| 51 | + root->node->start); | ||
| 52 | + if (rb_node) { | ||
| 53 | + node = rb_entry(rb_node, struct mapping_node, rb_node); | ||
| 54 | + rb_erase(&node->rb_node, &rc->reloc_root_tree.rb_root); | ||
| 55 | + } | ||
| 56 | + spin_unlock(&rc->reloc_root_tree.lock); | ||
| 57 | + if (!node) | ||
| 58 | + return; | ||
| 59 | + BUG_ON((struct btrfs_root *)node->data != root); | ||
| 60 | } | ||
| 61 | - spin_unlock(&rc->reloc_root_tree.lock); | ||
| 62 | - | ||
| 63 | - if (!node) | ||
| 64 | - return; | ||
| 65 | - BUG_ON((struct btrfs_root *)node->data != root); | ||
| 66 | |||
| 67 | spin_lock(&fs_info->trans_lock); | ||
| 68 | list_del_init(&root->root_list); | ||
| 69 | -- | ||
| 70 | 2.20.1 | ||
| 71 | |||
