Re: [PATCH][1/2] NX: Fix noexec kernel parameter

From: Zwane Mwaikambo
Date: Sun Dec 05 2004 - 02:27:00 EST


noexec_setup runs too late to take any effect, so parse it earlier.
Rediffed to incorporate suggestions.

Signed-off-by: Zwane Mwaikambo <zwane@xxxxxxxxxxxxxxxx>

Index: linux-2.6.10-rc2/include/asm-i386/pgtable.h
===================================================================
RCS file: /home/cvsroot/linux-2.6.10-rc2/include/asm-i386/pgtable.h,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 pgtable.h
--- linux-2.6.10-rc2/include/asm-i386/pgtable.h 25 Nov 2004 19:45:33 -0000 1.1.1.1
+++ linux-2.6.10-rc2/include/asm-i386/pgtable.h 5 Dec 2004 07:21:29 -0000
@@ -363,6 +363,8 @@ extern pte_t *lookup_address(unsigned lo
static inline int set_kernel_exec(unsigned long vaddr, int enable) { return 0;}
#endif

+extern void noexec_setup(const char *str);
+
#if defined(CONFIG_HIGHPTE)
#define pte_offset_map(dir, address) \
((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + pte_index(address))
Index: linux-2.6.10-rc2/arch/i386/kernel/setup.c
===================================================================
RCS file: /home/cvsroot/linux-2.6.10-rc2/arch/i386/kernel/setup.c,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 setup.c
--- linux-2.6.10-rc2/arch/i386/kernel/setup.c 25 Nov 2004 19:45:32 -0000 1.1.1.1
+++ linux-2.6.10-rc2/arch/i386/kernel/setup.c 5 Dec 2004 07:19:33 -0000
@@ -737,6 +737,10 @@ static void __init parse_cmdline_early (
}
}

+ else if (!memcmp(from, "noexec=", 7))
+ noexec_setup(from + 7);
+
+
#ifdef CONFIG_X86_SMP
/*
* If the BIOS enumerates physical processors before logical,
Index: linux-2.6.10-rc2/arch/i386/mm/init.c
===================================================================
RCS file: /home/cvsroot/linux-2.6.10-rc2/arch/i386/mm/init.c,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 init.c
--- linux-2.6.10-rc2/arch/i386/mm/init.c 25 Nov 2004 19:45:32 -0000 1.1.1.1
+++ linux-2.6.10-rc2/arch/i386/mm/init.c 5 Dec 2004 07:19:54 -0000
@@ -424,7 +424,7 @@ u64 __supported_pte_mask = ~_PAGE_NX;
* on Enable
* off Disable
*/
-static int __init noexec_setup(char *str)
+void __init noexec_setup(const char *str)
{
if (!strncmp(str, "on",2) && cpu_has_nx) {
__supported_pte_mask |= _PAGE_NX;
@@ -433,11 +433,8 @@ static int __init noexec_setup(char *str
disable_nx = 1;
__supported_pte_mask &= ~_PAGE_NX;
}
- return 1;
}

-__setup("noexec=", noexec_setup);
-
int nx_enabled = 0;
#ifdef CONFIG_X86_PAE

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/