From: Kees Cook <keescook@chromium.org>
To: Ingo Molnar <mingo@redhat.com>
Cc: linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
Jeremy Fitzhardinge <jeremy@goop.org>,
Kees Cook <keescook@chromium.org>,
Marcelo Tosatti <mtosatti@redhat.com>,
Alex Shi <alex.shi@intel.com>,
Borislav Petkov <borislav.petkov@amd.com>,
Alexander Duyck <alexander.h.duyck@intel.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
xen-devel@lists.xensource.com,
virtualization@lists.linux-foundation.org,
kernel-hardening@lists.openwall.com,
Dan Rosenberg <drosenberg@vsecurity.com>,
Julien Tinnes <jln@google.com>, Will Drewry <wad@chromium.org>,
Eric Northup <digitaleric@google.com>
Subject: [PATCH] x86: make IDT read-only
Date: Mon, 8 Apr 2013 15:43:29 -0700 [thread overview]
Message-ID: <20130408224328.GA17641@www.outflux.net> (raw)
This makes the IDT unconditionally read-only. This primarily removes
the IDT from being a target for arbitrary memory write attacks. It has
an added benefit of also not leaking (via the "sidt" instruction) the
kernel base offset, if it has been relocated.
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Eric Northup <digitaleric@google.com>
---
arch/x86/include/asm/fixmap.h | 4 +---
arch/x86/kernel/cpu/intel.c | 15 ---------------
arch/x86/kernel/traps.c | 8 ++++++++
arch/x86/xen/mmu.c | 4 +---
4 files changed, 10 insertions(+), 21 deletions(-)
diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
index a09c285..51b9e32 100644
--- a/arch/x86/include/asm/fixmap.h
+++ b/arch/x86/include/asm/fixmap.h
@@ -104,9 +104,7 @@ enum fixed_addresses {
FIX_LI_PCIA, /* Lithium PCI Bridge A */
FIX_LI_PCIB, /* Lithium PCI Bridge B */
#endif
-#ifdef CONFIG_X86_F00F_BUG
- FIX_F00F_IDT, /* Virtual mapping for IDT */
-#endif
+ FIX_RO_IDT, /* Virtual mapping for read-only IDT */
#ifdef CONFIG_X86_CYCLONE_TIMER
FIX_CYCLONE_TIMER, /*cyclone timer register*/
#endif
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 1905ce9..76148a3 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -164,20 +164,6 @@ int __cpuinit ppro_with_ram_bug(void)
return 0;
}
-#ifdef CONFIG_X86_F00F_BUG
-static void __cpuinit trap_init_f00f_bug(void)
-{
- __set_fixmap(FIX_F00F_IDT, __pa_symbol(idt_table), PAGE_KERNEL_RO);
-
- /*
- * Update the IDT descriptor and reload the IDT so that
- * it uses the read-only mapped virtual address.
- */
- idt_descr.address = fix_to_virt(FIX_F00F_IDT);
- load_idt(&idt_descr);
-}
-#endif
-
static void __cpuinit intel_smp_check(struct cpuinfo_x86 *c)
{
/* calling is from identify_secondary_cpu() ? */
@@ -215,7 +201,6 @@ static void __cpuinit intel_workarounds(struct cpuinfo_x86 *c)
c->f00f_bug = 1;
if (!f00f_workaround_enabled) {
- trap_init_f00f_bug();
printk(KERN_NOTICE "Intel Pentium with F0 0F bug - workaround enabled.\n");
f00f_workaround_enabled = 1;
}
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 68bda7a..a2a9b78 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -753,6 +753,14 @@ void __init trap_init(void)
#endif
/*
+ * Set the IDT descriptor to a fixed read-only location, so that the
+ * "sidt" instruction will not leak the location of the kernel, and
+ * to defend the IDT against arbitrary memory write vulnerabilities.
+ * It will be reloaded in cpu_init() */
+ __set_fixmap(FIX_RO_IDT, __pa_symbol(idt_table), PAGE_KERNEL_RO);
+ idt_descr.address = fix_to_virt(FIX_RO_IDT);
+
+ /*
* Should be a barrier for any external CPU state:
*/
cpu_init();
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 6afbb2c..8bc4dec 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -2039,9 +2039,7 @@ static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot)
switch (idx) {
case FIX_BTMAP_END ... FIX_BTMAP_BEGIN:
-#ifdef CONFIG_X86_F00F_BUG
- case FIX_F00F_IDT:
-#endif
+ case FIX_RO_IDT:
#ifdef CONFIG_X86_32
case FIX_WP_TEST:
case FIX_VDSO:
--
1.7.9.5
--
Kees Cook
Chrome OS Security
next reply other threads:[~2013-04-08 22:45 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-08 22:43 Kees Cook [this message]
2013-04-08 22:47 ` H. Peter Anvin
2013-04-08 22:55 ` Kees Cook
2013-04-08 22:48 ` H. Peter Anvin
2013-04-09 9:23 ` Thomas Gleixner
2013-04-09 18:22 ` [kernel-hardening] " Kees Cook
2013-04-09 18:26 ` H. Peter Anvin
2013-04-09 18:31 ` Kees Cook
2013-04-09 18:39 ` H. Peter Anvin
2013-04-09 18:46 ` Kees Cook
2013-04-09 18:50 ` H. Peter Anvin
2013-04-09 18:53 ` Kees Cook
2013-04-09 18:54 ` Eric Northup
2013-04-09 18:59 ` H. Peter Anvin
2013-04-10 0:43 ` Readonly GDT H. Peter Anvin
2013-04-10 0:53 ` Steven Rostedt
2013-04-10 0:58 ` H. Peter Anvin
2013-04-10 9:42 ` [Xen-devel] " Jan Beulich
2013-04-10 14:16 ` H. Peter Anvin
2013-04-10 18:28 ` H. Peter Anvin
2013-04-10 9:41 ` [kernel-hardening] Re: [PATCH] x86: make IDT read-only Ingo Molnar
2013-04-10 0:03 ` H. Peter Anvin
2013-04-10 9:52 ` Ingo Molnar
2013-04-09 9:45 ` Eric W. Biederman
2013-04-10 9:57 ` Ingo Molnar
2013-04-10 10:40 ` Eric W. Biederman
2013-04-10 16:31 ` Eric Northup
2013-04-10 16:48 ` H. Peter Anvin
2013-04-08 22:56 ` Maciej W. Rozycki
2013-04-08 23:00 ` Kees Cook
2013-04-08 23:05 ` Kees Cook
2013-04-08 23:42 ` Maciej W. Rozycki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130408224328.GA17641@www.outflux.net \
--to=keescook@chromium.org \
--cc=alex.shi@intel.com \
--cc=alexander.h.duyck@intel.com \
--cc=borislav.petkov@amd.com \
--cc=digitaleric@google.com \
--cc=drosenberg@vsecurity.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=jeremy@goop.org \
--cc=jln@google.com \
--cc=kernel-hardening@lists.openwall.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mtosatti@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=virtualization@lists.linux-foundation.org \
--cc=wad@chromium.org \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®