[PATCH] NX: Fix noexec kernel parameter / x86_64

From: Zwane Mwaikambo
Date: Sun Dec 05 2004 - 01:59:56 EST


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

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

Index: linux-2.6.10-rc2/arch/x86_64/kernel/setup.c
===================================================================
RCS file: /home/cvsroot/linux-2.6.10-rc2/arch/x86_64/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/x86_64/kernel/setup.c 25 Nov 2004 19:45:32 -0000 1.1.1.1
+++ linux-2.6.10-rc2/arch/x86_64/kernel/setup.c 5 Dec 2004 06:43:11 -0000
@@ -312,6 +312,12 @@ static __init void parse_cmdline_early (
if (!memcmp(from,"oops=panic", 10))
panic_on_oops = 1;

+ if (!memcmp(from, "noexec=", 7)) {
+ extern void nonx_setup(char *str);
+
+ nonx_setup(from + 7);
+ }
+
next_char:
c = *(from++);
if (!c)
Index: linux-2.6.10-rc2/arch/x86_64/kernel/setup64.c
===================================================================
RCS file: /home/cvsroot/linux-2.6.10-rc2/arch/x86_64/kernel/setup64.c,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 setup64.c
--- linux-2.6.10-rc2/arch/x86_64/kernel/setup64.c 25 Nov 2004 19:45:32 -0000 1.1.1.1
+++ linux-2.6.10-rc2/arch/x86_64/kernel/setup64.c 5 Dec 2004 06:43:49 -0000
@@ -50,7 +50,7 @@ Control non executable mappings for 64bi
on Enable(default)
off Disable
*/
-static int __init nonx_setup(char *str)
+void __init nonx_setup(char *str)
{
if (!strcmp(str, "on")) {
__supported_pte_mask |= _PAGE_NX;
@@ -59,11 +59,8 @@ static int __init nonx_setup(char *str)
do_not_nx = 1;
__supported_pte_mask &= ~_PAGE_NX;
}
- return 1;
}

-__setup("noexec=", nonx_setup);
-
/*
* Great future plan:
* Declare PDA itself and support (irqstack,tss,pml4) as per cpu data.
-
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/