x86: make sure IDT is page aligned
PATCH 1/1 x86: make sure IDT is page aligned
Since the IDT is referenced from a fixmap, make sure it is page aligned. This avoids the risk of it ever being moved in the bss and having the fixmap fail.
--- arch/x86/kernel/head_32.S | 2 +- arch/x86/kernel/head_64.S | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/head_32.S +1 -1
@@ -734,7 +734,7 @@ boot_gdt_descr: .word __BOOT_DS+7 .long boot_gdt - __PAGE_OFFSET - .word 0 # 32-bit align idt_desc.address + .word PAGE_SIZE # page align idt_desc.address idt_descr: .word IDT_ENTRIES*8-1 # idt contains 256 entries .long idt_table
arch/x86/kernel/head_64.S +1 -1
@@ -513,7 +513,7 @@ ENTRY(phys_base) #include "../../x86/xen/xen-head.S" .section .bss, "aw", @nobits - .align L1_CACHE_BYTES + .align PAGE_SIZE ENTRY(idt_table) .skip IDT_ENTRIES * 16
Signature · 6 lines
1.7.9.5 -- Kees Cook Chrome OS Security
H. Peter Anvin
reviewerQuoted 31 lines · Kees Cook
Since the IDT is referenced from a fixmap, make sure it is page aligned. This avoids the risk of it ever being moved in the bss and having the fixmap fail.
Signed-off-by Kees Cook <[email protected]>Reported-by PaX Team <[email protected]>--- arch/x86/kernel/head_32.S | 2 +- arch/x86/kernel/head_64.S | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)arch/x86/kernel/head_32.S +1
-1@@ -734,7 +734,7 @@ boot_gdt_descr: .word __BOOT_DS+7 .long boot_gdt - __PAGE_OFFSET - .word 0 # 32-bit align idt_desc.address + .word PAGE_SIZE # page align idt_desc.address idt_descr: .word IDT_ENTRIES*8-1 # idt contains 256 entries .long idt_tablearch/x86/kernel/head_64.S +0
-0
arch/x86/kernel/head_64.S ENTRY(phys_base) · line 519
Quoted 8 lines
arch/x86/kernel/head_64.S +1
-1@@ -513,7 +513,7 @@ ENTRY(phys_base) #include "../../x86/xen/xen-head.S" .section .bss, "aw", @nobits - .align L1_CACHE_BYTES + .align PAGE_SIZE ENTRY(idt_table) .skip IDT_ENTRIES * 16
You are aligning the IDT *descriptor*, not the IDT itself?
-hpa
H. Peter Anvin
reviewerarch/x86/kernel/head_32.S boot_gdt_descr: · line 737
Quoted 4 lines · Kees Cook
arch/x86/kernel/head_32.S +1
-1- .word 0 # 32-bit align idt_desc.address + .word PAGE_SIZE # page align idt_desc.address
... and this is totally confused. This didn't change alignment one iota, it only put the value 4096 into the padding.
-hpa
That was the busted patch. See the v2 I sent. Only 64-bit needs alignment. And after looking more at it, the idt in head_64.S could be entirely dropped in favor of using the one in arch/x86/kernel/traps.c (after moving it out of the #ifdef.
-Kees
Quoted 11 lines · H. Peter Anvin
arch/x86/kernel/head_32.S boot_gdt_descr: · line 737
Quoted 4 lines · Kees Cook
arch/x86/kernel/head_32.S +1
-1- .word 0 # 32-bit align idt_desc.address + .word PAGE_SIZE # page align idt_desc.address... and this is totally confused. This didn't change alignment one iota, it only put the value 4096 into the padding.
-hpa
Signature · 2 lines
Kees Cook Chrome OS Security