intel_txt: Intel(R) TXT and tboot kernel support
Subsystems (8)
RFC PATCH v4 2/2 intel_txt: Intel(R) TXT and tboot kernel support
Linux support for Intel(R) Trusted Execution Technology.
Documentation/intel_txt.txt | 187 +++++++++++++++++++++++ Documentation/x86/zero-page.txt | 1 arch/x86/include/asm/bootparam.h | 3 arch/x86/include/asm/fixmap.h | 3 arch/x86/include/asm/tboot.h | 159 ++++++++++++++++++++ arch/x86/kernel/Makefile | 1 arch/x86/kernel/reboot.c | 14 + arch/x86/kernel/setup.c | 4 arch/x86/kernel/smpboot.c | 6 arch/x86/kernel/tboot.c | 308 +++++++++++++++++++++++++++++++++++++++ drivers/acpi/acpica/hwsleep.c | 35 ++++ drivers/pci/dmar.c | 6 drivers/pci/intel-iommu.c | 26 +++ init/main.c | 3 kernel/cpu.c | 6 security/Kconfig | 22 ++ 16 files changed, 777 insertions(+), 7 deletions(-)
Signed-off-by: Joseph Cihula <[email protected]> Signed-off-by: Shane Wang <[email protected]> Signed-off-by: Gang Wei <[email protected]>
---
arch/x86/include/asm/bootparam.h +2 -1
@@ -84,7 +84,8 @@ struct efi_info {struct boot_params {struct screen_info screen_info;/* 0x000 */ struct apm_bios_info apm_bios_info;/* 0x040 */ -__u8 _pad2[12 ];/* 0x054 */ +__u8 _pad2[4 ];/* 0x054 */ +__u64 tboot_shared_addr;/* 0x058 */ struct ist_info ist_info;/* 0x060 */ __u8 _pad3[16 ];/* 0x070 */ __u8 hd0_info[16 ];/* obsolete! */ /* 0x080 */
arch/x86/include/asm/fixmap.h +3 -0
@@ -132,6 +132,9 @@ enum fixed_addresses {#ifdef CONFIG_X86_32 FIX_WP_TEST,#endif +#ifdef CONFIG_INTEL_TXT +FIX_TBOOT_SHARED_BASE , +#endif __end_of_fixed_addresses };
arch/x86/include/asm/tboot.h +159 -0
159 lines not on this page · raw message
arch/x86/kernel/Makefile +1 -0
@@ -47,6 +47,7 @@ obj-$(CONFIG_X86_DS) += ds.o obj-$(CONFIG_X86_32) += tls.o obj-$(CONFIG_IA32_EMULATION) += tls.o obj-y += step.o +obj-$(CONFIG_INTEL_TXT) += tboot.o obj-$(CONFIG_STACKTRACE) += stacktrace.o obj-y += cpu/ obj-y += acpi/
arch/x86/kernel/reboot.c +12 -2
@@ -24,6 +24,8 @@# include <asm/iommu.h> #endif +#include <asm/tboot.h> +/* * Power off function, if any */
@@ -451,6 +453,8 @@ static void native_machine_emergency_resif (reboot_emergency)emergency_vmx_disable_all (); +tboot_shutdown (TB_SHUTDOWN_REBOOT ); +/* Tell the BIOS if we want cold or warm reboot */ *((unsigned short *)__va (0x472 )) = reboot_mode;
@@ -516,11 +520,13 @@ static void native_machine_emergency_resvoid native_machine_shutdown (void ) { -/* Stop the cpus and apics */ #ifdef CONFIG_SMP -/* The boot cpu is always logical cpu 0 */ int reboot_cpu_id =0 ; +#endif + +/* Stop the cpus and apics */ +#ifdef CONFIG_SMP #ifdef CONFIG_X86_32 /* See if there has been given a command line override */
@@ -577,6 +583,8 @@ static void native_machine_halt(void)/* stop other cpus and apics */ machine_shutdown (); +tboot_shutdown (TB_SHUTDOWN_HALT ); +/* stop this cpu */ stop_this_cpu (NULL ); }
@@ -588,6 +596,8 @@ static void native_machine_power_off(voimachine_shutdown ();pm_power_off (); } +/* a fallback in case there is no PM info available */ +tboot_shutdown (TB_SHUTDOWN_HALT ); }struct machine_ops machine_ops = {
arch/x86/kernel/setup.c +4 -0
@@ -137,6 +137,8 @@ struct boot_params __initdata boot_paramstruct boot_params boot_params;#endif +#include <asm/tboot.h> +/* * Machine setup.. */
@@ -939,6 +941,8 @@ void __init setup_arch(char **cmdline_p)paravirt_pagetable_setup_done (swapper_pg_dir);paravirt_post_allocator_init (); +tboot_probe (); +#ifdef CONFIG_X86_64 map_vsyscall ();#endif
arch/x86/kernel/smpboot.c +5 -1
@@ -62,6 +62,7 @@#include <asm/vmi.h> #include <asm/apic.h> #include <asm/setup.h> +#include <asm/tboot.h> #include <asm/uv/uv.h> #include <linux/mc146818rtc.h>
@@ -1313,7 +1314,10 @@ void play_dead_common(void)void native_play_dead (void ) {play_dead_common (); -wbinvd_halt (); +if (tboot_in_measured_env ()) +tboot_shutdown (TB_SHUTDOWN_WFS ); +else +wbinvd_halt (); }#else /* ... !CONFIG_HOTPLUG_CPU */
arch/x86/kernel/tboot.c +308 -0
308 lines not on this page · raw message
Documentation/intel_txt.txt +187 -0
187 lines not on this page · raw message
Documentation/x86/zero-page.txt +1 -0
@@ -12,6 +12,7 @@ Offset Proto Name Meaning 000/040 ALL screen_info Text mode or frame buffer information (struct screen_info) 040/014 ALL apm_bios_info APM BIOS information (struct apm_bios_info) +058/008 ALL tboot_shared_addr Physical address of tboot shared page 060/010 ALL ist_info Intel SpeedStep (IST) BIOS support information (struct ist_info) 080/010 ALL hd0_info hd0 disk parameter, OBSOLETE!!
drivers/acpi/acpica/hwsleep.c +35 -0
@@ -45,6 +45,7 @@#include <acpi/acpi.h> #include "accommon.h" #include "actables.h" +#include <asm/tboot.h> #define _COMPONENT ACPI_HARDWAREACPI_MODULE_NAME ("hwsleep" )
@@ -342,6 +343,40 @@ acpi_status asmlinkage acpi_enter_sleep_ACPI_FLUSH_CPU_CACHE (); +#ifdef CONFIG_INTEL_TXT +#define TB_COPY_GAS (tbg, g) \ + tbg.space_id = g.space_id; \ + tbg.bit_width = g.bit_width; \ + tbg.bit_offset = g.bit_offset; \ + tbg.access_width = g.access_width; \ + tbg.address = g.address; + +if (tboot_in_measured_env ()) { +TB_COPY_GAS (tboot_shared->acpi_sinfo.pm1a_cnt_blk, + acpi_gbl_FADT.xpm1a_control_block); +TB_COPY_GAS (tboot_shared->acpi_sinfo.pm1b_cnt_blk, + acpi_gbl_FADT.xpm1b_control_block); +TB_COPY_GAS (tboot_shared->acpi_sinfo.pm1a_evt_blk, + acpi_gbl_FADT.xpm1a_event_block); +TB_COPY_GAS (tboot_shared->acpi_sinfo.pm1b_evt_blk, + acpi_gbl_FADT.xpm1b_event_block); + tboot_shared->acpi_sinfo.pm1a_cnt_val = pm1a_control; + tboot_shared->acpi_sinfo.pm1b_cnt_val = pm1b_control; +/* +* we need phys addr of waking vector, but can't use +* virt_to_phys() on &acpi_gbl_FACS because it is ioremap'ed, +* so calc from FACS phys addr +*/ + tboot_shared->acpi_sinfo.wakeup_vector = acpi_gbl_FADT.facs + + offsetof(struct acpi_table_facs , firmware_waking_vector); + tboot_shared->acpi_sinfo.vector_width =32 ; + tboot_shared->acpi_sinfo.kernel_s3_resume_vector = + acpi_wakeup_address; + +tboot_sleep (sleep_state); + } +#endif +/* Write #2: Write both SLP_TYP + SLP_EN */ status =acpi_hw_write_pm1_control (pm1a_control, pm1b_control);
drivers/pci/dmar.c +6 -0
@@ -33,6 +33,7 @@#include <linux/timer.h> #include <linux/irq.h> #include <linux/interrupt.h> +#include <asm/tboot.h> #undef PREFIX#define PREFIX "DMAR:"
@@ -329,6 +330,11 @@ parse_dmar_table(void)*/ dmar_table_detect (); +/* ACPI tables may not be DMA protected by tboot, so use DMAR copy */ +/* SINIT saved in SinitMleData in TXT heap (which is DMA protected) */ +if (tboot_in_measured_env ()) + dmar_tbl =tboot_get_dmar_table (); + dmar = (struct acpi_table_dmar *)dmar_tbl;if (!dmar)return -ENODEV ;
drivers/pci/intel-iommu.c +24 -2
@@ -38,6 +38,7 @@#include <linux/intel-iommu.h> #include <linux/sysdev.h> #include <asm/cacheflush.h> +#include <asm/tboot.h> #include <asm/iommu.h> #include "pci.h"
@@ -2780,12 +2781,31 @@ static int __init init_iommu_sysfs(void)int __init intel_iommu_init (void ) {int ret =0 ; +int force_on =0 ; -if (dmar_table_init ()) +/* VT-d is required for a TXT/tboot launch, so enforce that */ +if (tboot_in_measured_env ()) { +if (no_iommu || swiotlb || dmar_disabled) +printk (KERN_WARNING "TXT: Forcing Intel-IOMMU to enabled\n" ); + dmar_disabled =0 ; +#ifdef CONFIG_SWIOTLB + swiotlb =0 ; +#endif + no_iommu =0 ; + force_on =1 ; + } + +if (dmar_table_init ()) { +if (force_on) +panic ("TXT: Failed to initialize DMAR table\n" );return -ENODEV ; + } -if (dmar_dev_scope_init ()) +if (dmar_dev_scope_init ()) { +if (force_on) +panic ("TXT: Failed to initialize DMAR device scope\n" );return -ENODEV ; + }/* * Check the need for DMA-remapping initialization now.
@@ -2801,6 +2821,8 @@ int __init intel_iommu_init(void) ret =init_dmars ();if (ret) { +if (force_on) +panic ("TXT: Failed to initialize DMARs\n" );printk (KERN_ERR "IOMMU: dmar init failed\n" );put_iova_domain (&reserved_iova_list);iommu_exit_mempool ();
init/main.c +3 -0
@@ -69,6 +69,7 @@#include <asm/io.h> #include <asm/bugs.h> #include <asm/setup.h> +#include <asm/tboot.h> #include <asm/sections.h> #include <asm/cacheflush.h> #include <trace/kmemtrace.h>
@@ -695,6 +696,8 @@ asmlinkage void __init start_kernel(voidftrace_init (); +tboot_create_trampoline (); +/* Do the rest non-__init'ed, we're now alive */ rest_init (); }
kernel/cpu.c +5 -1
@@ -14,6 +14,7 @@#include <linux/kthread.h> #include <linux/stop_machine.h> #include <linux/mutex.h> +#include <asm/tboot.h> #ifdef CONFIG_SMP /* Serializes the updates to cpu_online_mask, cpu_present_mask */
@@ -379,7 +380,7 @@ static cpumask_var_t frozen_cpus;int disable_nonboot_cpus (void ) { -int cpu, first_cpu, error; +int cpu, first_cpu, error, num_cpus =0 ; error =stop_machine_create ();if (error)
@@ -394,6 +395,7 @@ int disable_nonboot_cpus(void)for_each_online_cpu (cpu) {if (cpu == first_cpu)continue ; + num_cpus++; error =_cpu_down (cpu,1 );if (!error) {cpumask_set_cpu (cpu, frozen_cpus);
@@ -404,6 +406,8 @@ int disable_nonboot_cpus(void)break ; } } +/* ensure all CPUs have gone into wait-for-SIPI */ +tboot_wait_for_aps (num_cpus);if (!error) {BUG_ON (num_online_cpus () >1 );/* Make sure the CPUs won't be enabled by someone else */
security/Kconfig +22 -0
@@ -133,6 +133,28 @@ config SECURITY_DEFAULT_MMAP_MIN_ADDR /proc/sys/vm/mmap_min_addr tunable. +config INTEL_TXT + bool "Enable Intel(R) Trusted Execution Technology (Intel(R) TXT)" + depends on EXPERIMENTAL && X86 && DMAR && ACPI + help + This option enables support for booting the kernel with the + Trusted Boot (tboot) module. This will utilize + Intel(R) Trusted Execution Technology to perform a measured launch + of the kernel. If the system does not support Intel(R) TXT, this + will have no effect. + + Intel TXT will provide higher assurance of sysem configuration and + initial state as well as data reset protection. This is used to + create a robust initial kernel measurement and verification. + + See <http://www.intel.com/technology/security/> for more information + about Intel(R) TXT. + See <http://tboot.sourceforge.net> for more information about tboot. + See Documentation/intel_txt.txt for a description of how to enable + Intel TXT support in a kernel boot. + + If you are unsure as to whether this is required, answer N. + source security/selinux/Kconfig source security/smack/Kconfig source security/tomoyo/Kconfig
Quoted 5 lines · Joseph Cihula
Linux support for Intel(R) Trusted Execution Technology.
Signed-off-by: Joseph Cihula <[email protected]> Signed-off-by: Shane Wang <[email protected]> Signed-off-by: Gang Wei <[email protected]>
There have been no comments on this since you posted it, so we might assume there are no further technical issues.
Ingo, this should probably be merged via your tree.
- James
Signature · 2 lines
James Morris <[email protected]>
Andi Kleen
Reviewed-byQuoted 9 lines · James Morris
Quoted 5 lines · Joseph Cihula
Linux support for Intel(R) Trusted Execution Technology.
Signed-off-by: Joseph Cihula <[email protected]> Signed-off-by: Shane Wang <[email protected]> Signed-off-by: Gang Wei <[email protected]>Reviewed-by James Morris <[email protected]>
The earlier version was also reviewed by me and I think Joe addressed all my concerns.
So it's
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.
Quoted 4 lines · James Morris
Quoted 1 line · Joseph Cihula
Linux support for Intel(R) Trusted Execution Technology.
Quoted 8 lines
Quoted 3 lines
Signed-off-by: Joseph Cihula <[email protected]> Signed-off-by: Shane Wang <[email protected]> Signed-off-by: Gang Wei <[email protected]>Reviewed-by James Morris <[email protected]>There have been no comments on this since you posted it, so we might assume there are no further technical issues.
I believe the code at best useless and at worst dangerous. We don't merge useless code to the kernel.
What are non-evil uses of this code?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 11 lines · Pavel Machek
Quoted 10 lines · James Morris
Quoted 5 lines · Joseph Cihula
Linux support for Intel(R) Trusted Execution Technology.
Signed-off-by: Joseph Cihula <[email protected]> Signed-off-by: Shane Wang <[email protected]> Signed-off-by: Gang Wei <[email protected]>Reviewed-by James Morris <[email protected]>
Quoted 7 lines
Quoted 2 lines
There have been no comments on this since you posted it, so we might assume there are no further technical issues.
I believe the code at best useless and at worst dangerous. We don't merge useless code to the kernel.
What are non-evil uses of this code?
Yes, most of the uses contemplated for this are for evil DRM schemes. On the other hand, the code is equally useful to help make sure that mo miscreant has snuck evil DRM (or other evil code) in behind my back.
"Somebody has screwed with this kernel image, and you're not booting what you thought you were booting."
Seems worth it to me.
Quoted 1 line · * Pavel Machek ([email protected]) wrote:
What are non-evil uses of this code?
The most common use case I've heard requested from real live customers[1] is...you guessed it...trusted boot.
This is typically in the context of virtualization and data centers or clouds. The concerns being addressed are:
* confidence that the hardware is running the VMM that the hardware owner configured it w/, since they are on the hook for providing a safe service for each VM running on that hardware
* flip side of that is an additional layer protecting against malicious VM that is using some VMM hole to try and subvert the host w/ a VMM of their own
thanks,
-chris
--
[1] as opposed to hardware vendors pushing a feature
Quoted 2 lines
"Somebody has screwed with this kernel image, and you're not booting what you thought you were booting."
So I screw with your user space - you can't measure enough to make it save you in a general setup. Too much I can hit changes each boot.
For a tiny number of very special cases that are highly controlled it has potential uses. Some of those are evil some are ones with meaningful uses (eg ATM machines) - although attacks there have included hardware attacks outside the PC components too.
Personally (and I'm sure Intel disagrees with me) my bigger work is that I can't verify that the magic block of code for tboot is correct.
Quoted 1 line
Personally (and I'm sure Intel disagrees with me) my bigger work
worry rather ;)
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Linux support for Intel(R) Trusted Execution Technology.
Signed-off-by: Joseph Cihula <[email protected]> Signed-off-by: Shane Wang <[email protected]> Signed-off-by: Gang Wei <[email protected]>Reviewed-by James Morris <[email protected]>Quoted 7 lines
Quoted 2 lines
There have been no comments on this since you posted it, so we might assume there are no further technical issues.
I believe the code at best useless and at worst dangerous. We don't merge useless code to the kernel.
What are non-evil uses of this code?
Quoted 8 lines
Yes, most of the uses contemplated for this are for evil DRM schemes. On the other hand, the code is equally useful to help make sure that mo miscreant has snuck evil DRM (or other evil code) in behind my back.
"Somebody has screwed with this kernel image, and you're not booting what you thought you were booting."
Seems worth it to me.
Unfortunately, I do not think you can boot linux kernel under TXT sandbox. (Is there some code that you can boot under TXT sandbox? If so, where?)
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
James Morris
maintainerQuoted 3 lines · Alan Cox
Quoted 1 line
Personally (and I'm sure Intel disagrees with me) my bigger work
worry rather ;)
Yes, I hope we hear more on the licensing of this blob -- I flagged it a while back.
- James
Signature · 2 lines
James Morris <[email protected]>
James Morris
maintainerQuoted 9 lines · Chris Wright
Quoted 1 line · * Pavel Machek ([email protected]) wrote:
What are non-evil uses of this code?
The most common use case I've heard requested from real live customers[1] is...you guessed it...trusted boot.
This is typically in the context of virtualization and data centers or clouds. The concerns being addressed are:
Quoted 7 lines
* confidence that the hardware is running the VMM that the hardware owner configured it w/, since they are on the hook for providing a safe service for each VM running on that hardware
* flip side of that is an additional layer protecting against malicious VM that is using some VMM hole to try and subvert the host w/ a VMM of their own
Agreed. I'd also mention (again), these slides on the topic by Joanna Rutkowska:
http://invisiblethingslab.com/resources/misc09/trusted_computing_thoughts.pdf
Also, hardware security measures such as TXT are important in providing stronger mechanisms to ensure that kernel security mechanisms are functioning correctly.
- James
Signature · 2 lines
James Morris <[email protected]>
Quoted 4 lines
Also, hardware security measures such as TXT are important in providing stronger mechanisms to ensure that kernel security mechanisms are functioning correctly.
I don't get it. How does TXT help kernel security mechanisms?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
James Morris
maintainerQuoted 6 lines · Pavel Machek
Quoted 4 lines
Also, hardware security measures such as TXT are important in providing stronger mechanisms to ensure that kernel security mechanisms are functioning correctly.
I don't get it. How does TXT help kernel security mechanisms?
Kernel security mechanisms can be subverted and bypassed in the case of an exploitable kernel vulnerability, or from exploitable buggy hardware (e.g. which can access the entire host's memory via DMA). Attacks on kernel security mechanisms have been describe in detail, see:
http://www.phrack.com/issues.html?issue=66&id=15#article
This is close to impossible to solve from within the kernel alone. Hardware support is required to allow protection of the IO space (e.g. via IOMMU/VT-d), and to allow verification of the kernel itself (via TXT).
A significant advance in this area is LKIM:
"Linux kernel integrity measurement using contextual inspection"
http://portal.acm.org/citation.cfm?id=1314354.1314362
(Unfortunately, the ACM has not made this freely available, although I understand that individual authors are allowed to distribute their own papers as they see fit).
- James
Signature · 2 lines
James Morris <[email protected]>
Quoted 15 lines · James Morris
Quoted 6 lines · Pavel Machek
Quoted 4 lines
Also, hardware security measures such as TXT are important in providing stronger mechanisms to ensure that kernel security mechanisms are functioning correctly.
I don't get it. How does TXT help kernel security mechanisms?
Kernel security mechanisms can be subverted and bypassed in the case of an exploitable kernel vulnerability, or from exploitable buggy hardware (e.g. which can access the entire host's memory via DMA). Attacks on kernel security mechanisms have been describe in detail, see:
http://www.phrack.com/issues.html?issue=66&id=15#article
Quoted 4 lines
This is close to impossible to solve from within the kernel alone. Hardware support is required to allow protection of the IO space (e.g. via IOMMU/VT-d), and to allow verification of the kernel itself (via TXT).
So... you can exploit kernel security holes. How does intel TXT help?
AFAICT it does not. From what I see, intel TXT only prevents user from physically tampering with his own machine. Preventing user from tampering with his own machine is immoral to me, and from what I've seen it will be ineffective as soon as user suspends the machine, uses some liquid nitrogen, does whatever he needs with the RAM modules, and then places them back.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html