Patchwork UBUNTU: SAUCE: [x86] fix report of cs-limit nx-emulation

login
register
mail settings
Submitter Kees Cook
Date Oct. 18, 2009, 12:08 a.m.
Message ID <20091018000835.GF5394@outflux.net>
Download mbox | patch
Permalink /patch/36320/
State Superseded
Headers show

Comments

Kees Cook - Oct. 18, 2009, 12:08 a.m.
This is an addition to the patch titled "UBUNTU: SAUCE: [x86] implement
cs-limit nx-emulation for ia32" which correctly limits the report about
NX capabilities to actual hardware and arch details.

BugLink: http://bugs.launchpad.net/bugs/454285

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

Patch

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 10de7ed..2044967 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -77,6 +77,7 @@  static void __init set_nx(void)
 #else
 static inline void set_nx(void)
 {
+	nx_enabled = ( (__supported_pte_mask & _PAGE_NX) == _PAGE_NX );
 }
 #endif
 
@@ -213,8 +214,13 @@  unsigned long __init_refok init_memory_mapping(unsigned long start,
 	if (nx_enabled)
 		printk(KERN_INFO "NX (Execute Disable) protection: active\n");
 	else
+#ifdef CONFIG_X86_32
 		printk(KERN_INFO "Using x86 segment limits to approximate "
 			"NX protection\n");
+#else
+		printk(KERN_WARNING "Yikes! NX (Execute Disable) protection "
+			"is missing/disabled in CPU or BIOS!\n");
+#endif
 
 	/* Enable PSE if available */
 	if (cpu_has_pse)