]>
Commit | Line | Data |
---|---|---|
59d5af67 | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
321d628a FG |
2 | From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> |
3 | Date: Tue, 7 Nov 2017 11:33:37 +0300 | |
59d5af67 | 4 | Subject: [PATCH] mm/sparsemem: Fix ARM64 boot crash when |
321d628a FG |
5 | CONFIG_SPARSEMEM_EXTREME=y |
6 | MIME-Version: 1.0 | |
7 | Content-Type: text/plain; charset=UTF-8 | |
8 | Content-Transfer-Encoding: 8bit | |
9 | ||
10 | CVE-2017-5754 | |
11 | ||
12 | Since commit: | |
13 | ||
14 | 83e3c48729d9 ("mm/sparsemem: Allocate mem_section at runtime for CONFIG_SPARSEMEM_EXTREME=y") | |
15 | ||
16 | we allocate the mem_section array dynamically in sparse_memory_present_with_active_regions(), | |
17 | but some architectures, like arm64, don't call the routine to initialize sparsemem. | |
18 | ||
19 | Let's move the initialization into memory_present() it should cover all | |
20 | architectures. | |
21 | ||
22 | Reported-and-tested-by: Sudeep Holla <sudeep.holla@arm.com> | |
23 | Tested-by: Bjorn Andersson <bjorn.andersson@linaro.org> | |
24 | Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> | |
25 | Acked-by: Will Deacon <will.deacon@arm.com> | |
26 | Cc: Andrew Morton <akpm@linux-foundation.org> | |
27 | Cc: Linus Torvalds <torvalds@linux-foundation.org> | |
28 | Cc: Peter Zijlstra <peterz@infradead.org> | |
29 | Cc: Thomas Gleixner <tglx@linutronix.de> | |
30 | Cc: linux-mm@kvack.org | |
31 | Fixes: 83e3c48729d9 ("mm/sparsemem: Allocate mem_section at runtime for CONFIG_SPARSEMEM_EXTREME=y") | |
32 | Link: http://lkml.kernel.org/r/20171107083337.89952-1-kirill.shutemov@linux.intel.com | |
33 | Signed-off-by: Ingo Molnar <mingo@kernel.org> | |
34 | (cherry picked from commit 629a359bdb0e0652a8227b4ff3125431995fec6e) | |
35 | Signed-off-by: Andy Whitcroft <apw@canonical.com> | |
36 | Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com> | |
37 | (cherry picked from commit fbc3acbf37de68310eb5bbc7f4d1977e7b90100e) | |
38 | Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> | |
39 | --- | |
40 | mm/page_alloc.c | 10 ---------- | |
41 | mm/sparse.c | 10 ++++++++++ | |
42 | 2 files changed, 10 insertions(+), 10 deletions(-) | |
43 | ||
44 | diff --git a/mm/page_alloc.c b/mm/page_alloc.c | |
45 | index 66eb23ab658d..1423da8dd16f 100644 | |
46 | --- a/mm/page_alloc.c | |
47 | +++ b/mm/page_alloc.c | |
48 | @@ -5707,16 +5707,6 @@ void __init sparse_memory_present_with_active_regions(int nid) | |
49 | unsigned long start_pfn, end_pfn; | |
50 | int i, this_nid; | |
51 | ||
52 | -#ifdef CONFIG_SPARSEMEM_EXTREME | |
53 | - if (!mem_section) { | |
54 | - unsigned long size, align; | |
55 | - | |
56 | - size = sizeof(struct mem_section) * NR_SECTION_ROOTS; | |
57 | - align = 1 << (INTERNODE_CACHE_SHIFT); | |
58 | - mem_section = memblock_virt_alloc(size, align); | |
59 | - } | |
60 | -#endif | |
61 | - | |
62 | for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, &this_nid) | |
63 | memory_present(this_nid, start_pfn, end_pfn); | |
64 | } | |
65 | diff --git a/mm/sparse.c b/mm/sparse.c | |
66 | index 308a0789d1bb..9c48e4fe8ce0 100644 | |
67 | --- a/mm/sparse.c | |
68 | +++ b/mm/sparse.c | |
69 | @@ -210,6 +210,16 @@ void __init memory_present(int nid, unsigned long start, unsigned long end) | |
70 | { | |
71 | unsigned long pfn; | |
72 | ||
73 | +#ifdef CONFIG_SPARSEMEM_EXTREME | |
74 | + if (unlikely(!mem_section)) { | |
75 | + unsigned long size, align; | |
76 | + | |
77 | + size = sizeof(struct mem_section) * NR_SECTION_ROOTS; | |
78 | + align = 1 << (INTERNODE_CACHE_SHIFT); | |
79 | + mem_section = memblock_virt_alloc(size, align); | |
80 | + } | |
81 | +#endif | |
82 | + | |
83 | start &= PAGE_SECTION_MASK; | |
84 | mminit_validate_memmodel_limits(&start, &end); | |
85 | for (pfn = start; pfn < end; pfn += PAGES_PER_SECTION) { | |
86 | -- | |
87 | 2.14.2 | |
88 |