x86: make sure IDT is page aligned
PATCH v4 1/1 x86: make sure IDT is page aligned
Since the IDT is referenced from a fixmap, make sure it is page aligned. Merge with 32-bit one, since it was already aligned to deal with the F00F bug. Since bss is cleared before IDT setup, it can live there. This also moves the other *_idt_table variables into common locations.
This avoids the risk of the IDT ever being moved in the bss and having the mapping be offset, resulting in calling incorrect handlers. In the current upstream kernel this is not a manifested bug, but heavily patched kernels (such as those using the PaX patch series) did encounter this bug.
---
v4:
- rework using __page_aligned_bss, suggested by Yinghai LU
- move all the other IDT variables as well, suggested by HPA
v3:
- merge 32-bit and 64-bit idt_table definition
v2:
- 32-bit was already aligned
--- arch/x86/kernel/head_64.S | 15 --------------- arch/x86/kernel/tracepoint.c | 5 +---- arch/x86/kernel/traps.c | 11 +++++------ 3 files changed, 6 insertions(+), 25 deletions(-)
arch/x86/kernel/head_64.S +0 -15
@@ -512,21 +512,6 @@ ENTRY(phys_base) #include "../../x86/xen/xen-head.S" - .section .bss, "aw", @nobits - .align L1_CACHE_BYTES -ENTRY(idt_table) - .skip IDT_ENTRIES * 16 - - .align L1_CACHE_BYTES -ENTRY(debug_idt_table) - .skip IDT_ENTRIES * 16 - -#ifdef CONFIG_TRACING - .align L1_CACHE_BYTES -ENTRY(trace_idt_table) - .skip IDT_ENTRIES * 16 -#endif - __PAGE_ALIGNED_BSS NEXT_PAGE(empty_zero_page) .skip PAGE_SIZE
arch/x86/kernel/tracepoint.c +1 -4
@@ -12,10 +12,7 @@ atomic_t trace_idt_ctr = ATOMIC_INIT(0);struct desc_ptr trace_idt_descr = {NR_VECTORS *16 -1 , (unsigned long ) trace_idt_table }; -#ifndef CONFIG_X86_64 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_data - = { { { {0 ,0 } } }, }; -#endif +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;static int trace_irq_vector_refcount;static DEFINE_MUTEX (irq_vector_mutex);
arch/x86/kernel/traps.c +5 -6
@@ -63,19 +63,18 @@#include <asm/x86_init.h> #include <asm/pgalloc.h> #include <asm/proto.h> + +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;#else #include <asm/processor-flags.h> #include <asm/setup.h> asmlinkage int system_call(void); - -/* -* The IDT has to be page-aligned to simplify the Pentium -* F0 0F bug workaround. -*/ -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };#endif +/* Since it is used in a fixmap, the IDT has to be page-aligned. */ +gate_desc idt_table[NR_VECTORS] __page_aligned_bss; +DECLARE_BITMAP (used_vectors,NR_VECTORS );EXPORT_SYMBOL_GPL (used_vectors);
Signature · 6 lines
1.7.9.5 -- Kees Cook Chrome OS Security