All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [x86] detect and report lack of NX protections
@ 2009-10-19 18:42 Kees Cook
  2009-10-19 23:43 ` Arjan van de Ven
  0 siblings, 1 reply; 23+ messages in thread
From: Kees Cook @ 2009-10-19 18:42 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Pekka Enberg,
	Jan Beulich, Vegard Nossum, Yinghai Lu, Jeremy Fitzhardinge,
	linux-kernel

It is possible for x86_64 systems to lack the NX bit (see check_efer())
either due to the hardware lacking support or the BIOS having turned
off the CPU capability, so NX status should be reported.  Additionally,
anyone booting NX-capable CPUs in 32bit mode without PAE will lack NX
functionality, so this change provides feedback for that case as well.

Signed-off-by: Kees Cook <kees.cook@canonical.com>
---
 arch/x86/mm/init.c     |   10 ++++++++++
 arch/x86/mm/setup_nx.c |    2 ++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 73ffd55..8472293 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -149,6 +149,16 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
 	set_nx();
 	if (nx_enabled)
 		printk(KERN_INFO "NX (Execute Disable) protection: active\n");
+	else if (cpu_has_pae)
+#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
+		/* PAE kernel, PAE CPU, without NX */
+		printk(KERN_WARNING "Warning: NX (Execute Disable) protection "
+		       "missing in CPU or disabled in BIOS!\n");
+#else
+		/* 32bit non-PAE kernel, PAE CPU */
+		printk(KERN_WARNING "Warning: NX (Execute Disable) protection "
+		       "cannot be enabled: non-PAE kernel!\n");
+#endif
 
 	/* Enable PSE if available */
 	if (cpu_has_pse)
diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
index 513d8ed..b039a4c 100644
--- a/arch/x86/mm/setup_nx.c
+++ b/arch/x86/mm/setup_nx.c
@@ -53,6 +53,8 @@ void __init set_nx(void)
 #else
 void set_nx(void)
 {
+	/* notice if _PAGE_NX was removed during check_efer() */
+	nx_enabled = ((__supported_pte_mask & _PAGE_NX) == _PAGE_NX);
 }
 #endif
 
-- 
1.6.3.3


-- 
Kees Cook
Ubuntu Security Team

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2009-11-12 18:01 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-19 18:42 [PATCH] [x86] detect and report lack of NX protections Kees Cook
2009-10-19 23:43 ` Arjan van de Ven
2009-10-20  2:04   ` [PATCH v2] " Kees Cook
2009-10-20  2:18     ` H. Peter Anvin
2009-10-20  4:44       ` Kees Cook
2009-10-20  4:55       ` [PATCH v3] " Kees Cook
2009-11-09 22:10         ` [PATCH v4] " Kees Cook
2009-11-09 23:16           ` H. Peter Anvin
2009-11-10 15:49             ` Kees Cook
2009-11-10 16:47               ` H. Peter Anvin
2009-11-10 16:57                 ` Kees Cook
2009-11-10 17:12                   ` H. Peter Anvin
2009-11-10 17:46                     ` Kees Cook
2009-11-10 18:53                       ` H. Peter Anvin
2009-11-10 19:43                         ` Kees Cook
2009-11-10 19:59                           ` H. Peter Anvin
2009-11-10 20:55                             ` Kees Cook
2009-11-10 21:22                               ` H. Peter Anvin
2009-11-10 22:15                                 ` Kees Cook
2009-11-10 22:25                                   ` H. Peter Anvin
2009-11-12 18:01                               ` Yuhong Bao
2009-11-10 20:25                           ` H. Peter Anvin
2009-11-10 16:55           ` [PATCH v5] " Kees Cook

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.