diff options
| author | Alexander Potapenko <glider@google.com> | 2017-08-16 15:08:08 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2017-08-17 03:53:00 -0400 |
| commit | 187e91fe5e915f4b7f39b824aa422493463e443d (patch) | |
| tree | 4b2c8fe90f4d4be61b2a25ceb1c5a6fe20d6aad0 | |
| parent | 01578e36163cdd0e4fd61d9976de15f13364e26d (diff) | |
x86/boot/64/clang: Use fixup_pointer() to access 'next_early_pgt'
__startup_64() is normally using fixup_pointer() to access globals in a
position-independent fashion. However 'next_early_pgt' was accessed
directly, which wasn't guaranteed to work.
Luckily GCC was generating a R_X86_64_PC32 PC-relative relocation for
'next_early_pgt', but Clang emitted a R_X86_64_32S, which led to
accessing invalid memory and rebooting the kernel.
Signed-off-by: Alexander Potapenko <glider@google.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michael Davidson <md@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: c88d71508e36 ("x86/boot/64: Rewrite startup_64() in C")
Link: http://lkml.kernel.org/r/20170816190808.131748-1-glider@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
| -rw-r--r-- | arch/x86/kernel/head64.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index 46c3c73e7f43..9ba79543d9ee 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c | |||
| @@ -53,6 +53,7 @@ void __head __startup_64(unsigned long physaddr) | |||
| 53 | pudval_t *pud; | 53 | pudval_t *pud; |
| 54 | pmdval_t *pmd, pmd_entry; | 54 | pmdval_t *pmd, pmd_entry; |
| 55 | int i; | 55 | int i; |
| 56 | unsigned int *next_pgt_ptr; | ||
| 56 | 57 | ||
| 57 | /* Is the address too large? */ | 58 | /* Is the address too large? */ |
| 58 | if (physaddr >> MAX_PHYSMEM_BITS) | 59 | if (physaddr >> MAX_PHYSMEM_BITS) |
| @@ -91,9 +92,9 @@ void __head __startup_64(unsigned long physaddr) | |||
| 91 | * creates a bunch of nonsense entries but that is fine -- | 92 | * creates a bunch of nonsense entries but that is fine -- |
| 92 | * it avoids problems around wraparound. | 93 | * it avoids problems around wraparound. |
| 93 | */ | 94 | */ |
| 94 | 95 | next_pgt_ptr = fixup_pointer(&next_early_pgt, physaddr); | |
| 95 | pud = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); | 96 | pud = fixup_pointer(early_dynamic_pgts[(*next_pgt_ptr)++], physaddr); |
| 96 | pmd = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); | 97 | pmd = fixup_pointer(early_dynamic_pgts[(*next_pgt_ptr)++], physaddr); |
| 97 | 98 | ||
| 98 | if (IS_ENABLED(CONFIG_X86_5LEVEL)) { | 99 | if (IS_ENABLED(CONFIG_X86_5LEVEL)) { |
| 99 | p4d = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); | 100 | p4d = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); |
