Skip to content

Commit 4df05f3

Browse files
keesH. Peter Anvin
authored andcommitted
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 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. The tables other than idt_table technically do not need to be page aligned, at least not at the current time, but using a common declaration avoids mistakes. On 64 bits the table is exactly one page long, anyway. Signed-off-by: Kees Cook <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Reported-by: PaX Team <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
1 parent 5ff560f commit 4df05f3

File tree

3 files changed

+8
-25
lines changed

3 files changed

+8
-25
lines changed

arch/x86/kernel/head_64.S

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -512,21 +512,6 @@ ENTRY(phys_base)
512512

513513
#include "../../x86/xen/xen-head.S"
514514

515-
.section .bss, "aw", @nobits
516-
.align L1_CACHE_BYTES
517-
ENTRY(idt_table)
518-
.skip IDT_ENTRIES * 16
519-
520-
.align L1_CACHE_BYTES
521-
ENTRY(debug_idt_table)
522-
.skip IDT_ENTRIES * 16
523-
524-
#ifdef CONFIG_TRACING
525-
.align L1_CACHE_BYTES
526-
ENTRY(trace_idt_table)
527-
.skip IDT_ENTRIES * 16
528-
#endif
529-
530515
__PAGE_ALIGNED_BSS
531516
NEXT_PAGE(empty_zero_page)
532517
.skip PAGE_SIZE

arch/x86/kernel/tracepoint.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ atomic_t trace_idt_ctr = ATOMIC_INIT(0);
1212
struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
1313
(unsigned long) trace_idt_table };
1414

15-
#ifndef CONFIG_X86_64
16-
gate_desc trace_idt_table[NR_VECTORS] __page_aligned_data
17-
= { { { { 0, 0 } } }, };
18-
#endif
15+
/* No need to be aligned, but done to keep all IDTs defined the same way. */
16+
gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
1917

2018
static int trace_irq_vector_refcount;
2119
static DEFINE_MUTEX(irq_vector_mutex);

arch/x86/kernel/traps.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@
6363
#include <asm/x86_init.h>
6464
#include <asm/pgalloc.h>
6565
#include <asm/proto.h>
66+
67+
/* No need to be aligned, but done to keep all IDTs defined the same way. */
68+
gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
6669
#else
6770
#include <asm/processor-flags.h>
6871
#include <asm/setup.h>
6972

7073
asmlinkage int system_call(void);
71-
72-
/*
73-
* The IDT has to be page-aligned to simplify the Pentium
74-
* F0 0F bug workaround.
75-
*/
76-
gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
7774
#endif
7875

76+
/* Must be page-aligned because the real IDT is used in a fixmap. */
77+
gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
78+
7979
DECLARE_BITMAP(used_vectors, NR_VECTORS);
8080
EXPORT_SYMBOL_GPL(used_vectors);
8181

0 commit comments

Comments
 (0)