linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][1/2] NX: Fix noexec kernel parameter
@ 2004-12-05  5:58 Zwane Mwaikambo
  2004-12-05  6:57 ` [PATCH] NX: Fix noexec kernel parameter / x86_64 Zwane Mwaikambo
  2004-12-05  7:24 ` [PATCH][1/2] NX: Fix noexec kernel parameter Zwane Mwaikambo
  0 siblings, 2 replies; 7+ messages in thread
From: Zwane Mwaikambo @ 2004-12-05  5:58 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Linux Kernel, Andrew Morton

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

Signed-off-by: Zwane Mwaikambo <zwane@arm.linux.org.uk>

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	4 Dec 2004 18:43:17 -0000
@@ -737,6 +737,12 @@ static void __init parse_cmdline_early (
 			}
 		}
 
+		else if (!memcmp(from, "noexec=", 7)) {
+			extern void noexec_setup(char *str);
+
+			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	4 Dec 2004 18:42:40 -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(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
 

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

* [PATCH] NX: Fix noexec kernel parameter / x86_64
  2004-12-05  5:58 [PATCH][1/2] NX: Fix noexec kernel parameter Zwane Mwaikambo
@ 2004-12-05  6:57 ` Zwane Mwaikambo
  2004-12-05  6:59   ` Ingo Molnar
  2004-12-05  7:18   ` Zwane Mwaikambo
  2004-12-05  7:24 ` [PATCH][1/2] NX: Fix noexec kernel parameter Zwane Mwaikambo
  1 sibling, 2 replies; 7+ messages in thread
From: Zwane Mwaikambo @ 2004-12-05  6:57 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Linux Kernel, Andrew Morton, Andi Kleen

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

Signed-off-by: Zwane Mwaikambo <zwane@arm.linux.org.uk>

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.

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

* Re: [PATCH] NX: Fix noexec kernel parameter / x86_64
  2004-12-05  6:57 ` [PATCH] NX: Fix noexec kernel parameter / x86_64 Zwane Mwaikambo
@ 2004-12-05  6:59   ` Ingo Molnar
  2004-12-05  7:08     ` Zwane Mwaikambo
  2004-12-05  7:18   ` Zwane Mwaikambo
  1 sibling, 1 reply; 7+ messages in thread
From: Ingo Molnar @ 2004-12-05  6:59 UTC (permalink / raw)
  To: Zwane Mwaikambo; +Cc: Linux Kernel, Andrew Morton, Andi Kleen


* Zwane Mwaikambo <zwane@arm.linux.org.uk> wrote:

> +		if (!memcmp(from, "noexec=", 7)) {
> +			extern void nonx_setup(char *str);
> +	
> +			nonx_setup(from + 7);
> +		}

looks good, but please put the prototype into a header.

	Ingo

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

* Re: [PATCH] NX: Fix noexec kernel parameter / x86_64
  2004-12-05  6:59   ` Ingo Molnar
@ 2004-12-05  7:08     ` Zwane Mwaikambo
  2004-12-05 10:33       ` Ingo Molnar
  0 siblings, 1 reply; 7+ messages in thread
From: Zwane Mwaikambo @ 2004-12-05  7:08 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Linux Kernel, Andrew Morton, Andi Kleen

On Sun, 5 Dec 2004, Ingo Molnar wrote:

> 
> * Zwane Mwaikambo <zwane@arm.linux.org.uk> wrote:
> 
> > +		if (!memcmp(from, "noexec=", 7)) {
> > +			extern void nonx_setup(char *str);
> > +	
> > +			nonx_setup(from + 7);
> > +		}
> 
> looks good, but please put the prototype into a header.

I bet Andrew is going to say the same thing... It just seems odd putting a 
prototype in a header for a function with one call site and gets freed 
after boot. Since i'll have to rediff, i'm also going to change the 
nonx_setup parameter type to const char * as suggested by someone in a 
private email.

Thanks,
	Zwane


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

* Re: [PATCH] NX: Fix noexec kernel parameter / x86_64
  2004-12-05  6:57 ` [PATCH] NX: Fix noexec kernel parameter / x86_64 Zwane Mwaikambo
  2004-12-05  6:59   ` Ingo Molnar
@ 2004-12-05  7:18   ` Zwane Mwaikambo
  1 sibling, 0 replies; 7+ messages in thread
From: Zwane Mwaikambo @ 2004-12-05  7:18 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Linux Kernel, Andrew Morton, Andi Kleen

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

Signed-off-by: Zwane Mwaikambo <zwane@arm.linux.org.uk>

Index: linux-2.6.10-rc2-mm3-x86_64/include/asm-x86_64/pgtable.h
===================================================================
RCS file: /home/cvsroot/linux-2.6.10-rc2-mm3/include/asm-x86_64/pgtable.h,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 pgtable.h
--- linux-2.6.10-rc2-mm3-x86_64/include/asm-x86_64/pgtable.h	24 Nov 2004 16:14:38 -0000	1.1.1.1
+++ linux-2.6.10-rc2-mm3-x86_64/include/asm-x86_64/pgtable.h	5 Dec 2004 07:14:44 -0000
@@ -20,6 +20,7 @@ extern unsigned long __supported_pte_mas
 
 #define swapper_pml4 init_level4_pgt
 
+extern void nonx_setup(const char *str);
 extern void paging_init(void);
 extern void clear_kernel_mapping(unsigned long addr, unsigned long size);
 
Index: linux-2.6.10-rc2-mm3-x86_64/arch/x86_64/kernel/setup.c
===================================================================
RCS file: /home/cvsroot/linux-2.6.10-rc2-mm3/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-mm3-x86_64/arch/x86_64/kernel/setup.c	24 Nov 2004 16:17:13 -0000	1.1.1.1
+++ linux-2.6.10-rc2-mm3-x86_64/arch/x86_64/kernel/setup.c	5 Dec 2004 07:14:59 -0000
@@ -312,6 +312,9 @@ static __init void parse_cmdline_early (
 		if (!memcmp(from,"oops=panic", 10))
 			panic_on_oops = 1;
 
+		if (!memcmp(from, "noexec=", 7))
+			nonx_setup(from + 7);
+
 	next_char:
 		c = *(from++);
 		if (!c)
Index: linux-2.6.10-rc2-mm3-x86_64/arch/x86_64/kernel/setup64.c
===================================================================
RCS file: /home/cvsroot/linux-2.6.10-rc2-mm3/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-mm3-x86_64/arch/x86_64/kernel/setup64.c	24 Nov 2004 16:17:12 -0000	1.1.1.1
+++ linux-2.6.10-rc2-mm3-x86_64/arch/x86_64/kernel/setup64.c	5 Dec 2004 07:13:58 -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(const 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.

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

* Re: [PATCH][1/2] NX: Fix noexec kernel parameter
  2004-12-05  5:58 [PATCH][1/2] NX: Fix noexec kernel parameter Zwane Mwaikambo
  2004-12-05  6:57 ` [PATCH] NX: Fix noexec kernel parameter / x86_64 Zwane Mwaikambo
@ 2004-12-05  7:24 ` Zwane Mwaikambo
  1 sibling, 0 replies; 7+ messages in thread
From: Zwane Mwaikambo @ 2004-12-05  7:24 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Linux Kernel, Andrew Morton

noexec_setup runs too late to take any effect, so parse it earlier. 
Rediffed to incorporate suggestions.
 
Signed-off-by: Zwane Mwaikambo <zwane@arm.linux.org.uk>

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
 

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

* Re: [PATCH] NX: Fix noexec kernel parameter / x86_64
  2004-12-05  7:08     ` Zwane Mwaikambo
@ 2004-12-05 10:33       ` Ingo Molnar
  0 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2004-12-05 10:33 UTC (permalink / raw)
  To: Zwane Mwaikambo; +Cc: Linux Kernel, Andrew Morton, Andi Kleen


* Zwane Mwaikambo <zwane@arm.linux.org.uk> wrote:

> > > +		if (!memcmp(from, "noexec=", 7)) {
> > > +			extern void nonx_setup(char *str);
> > > +	
> > > +			nonx_setup(from + 7);
> > > +		}
> > 
> > looks good, but please put the prototype into a header.
> 
> I bet Andrew is going to say the same thing... It just seems odd
> putting a prototype in a header for a function with one call site and
> gets freed after boot. Since i'll have to rediff, i'm also going to
> change the nonx_setup parameter type to const char * as suggested by
> someone in a private email.

too many times did stuff break in the past due to some function changing
some attribute later on but the prototype being misdefined in another
place and the compiler having no chance to detect it.

	Ingo

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

end of thread, other threads:[~2004-12-05 10:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-05  5:58 [PATCH][1/2] NX: Fix noexec kernel parameter Zwane Mwaikambo
2004-12-05  6:57 ` [PATCH] NX: Fix noexec kernel parameter / x86_64 Zwane Mwaikambo
2004-12-05  6:59   ` Ingo Molnar
2004-12-05  7:08     ` Zwane Mwaikambo
2004-12-05 10:33       ` Ingo Molnar
2004-12-05  7:18   ` Zwane Mwaikambo
2004-12-05  7:24 ` [PATCH][1/2] NX: Fix noexec kernel parameter Zwane Mwaikambo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).