]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
x86: mark the .rodata section also NX
authorArjan van de Ven <arjan@linux.intel.com>
Wed, 6 Feb 2008 21:39:45 +0000 (22:39 +0100)
committerIngo Molnar <mingo@elte.hu>
Wed, 6 Feb 2008 21:39:45 +0000 (22:39 +0100)
The .rodata section shouldn't just be read-only,
but also non-executable. This is free since we've broken
up the 2MB page already anyway.

also update test_nx to check for this.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/test_nx.c
arch/x86/mm/init_64.c

index 36c100c323aa5d1a01d0fdf2316deeba5c3c37ec..10b8a6f69f84d51348827655903580cdfa6a5e93 100644 (file)
@@ -139,7 +139,6 @@ static int test_NX(void)
         * Until then, don't run them to avoid too many people getting scared
         * by the error message
         */
-#if 0
 
 #ifdef CONFIG_DEBUG_RODATA
        /* Test 3: Check if the .rodata section is executable */
@@ -152,6 +151,7 @@ static int test_NX(void)
        }
 #endif
 
+#if 0
        /* Test 4: Check if the .data section of a module is executable */
        if (test_address(&test_data)) {
                printk(KERN_ERR "test_nx: .data section is executable\n");
index 3a98d6f724ab69b9ed4d075a0a14895efe482dbc..9b61c75a23556f76898ca2f8b1d26d71b206ca26 100644 (file)
@@ -591,10 +591,17 @@ void mark_rodata_ro(void)
        if (end <= start)
                return;
 
-       set_memory_ro(start, (end - start) >> PAGE_SHIFT);
 
        printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n",
               (end - start) >> 10);
+       set_memory_ro(start, (end - start) >> PAGE_SHIFT);
+
+       /*
+        * The rodata section (but not the kernel text!) should also be
+        * not-executable.
+        */
+       start = ((unsigned long)__start_rodata + PAGE_SIZE - 1) & PAGE_MASK;
+       set_memory_nx(start, (end - start) >> PAGE_SHIFT);
 
        rodata_test();