Re: crashme fault

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Randy Dunlap <randy.dunlap@...>
Cc: Andi Kleen <andi@...>, lkml <linux-kernel@...>, Andi Kleen <ak@...>
Date: Saturday, September 15, 2007 - 8:34 pm

On Sat, 15 Sep 2007, Randy Dunlap wrote:

Ok, that's close to what I was testing (one of the examples from the 
crashme docs).


Yeah, by default, it won't do a mprotect(), so as far as I can tell, 
you're always going to hit NX on a writable data page. I'm running with 
the appended patch.

That said, I didn't actually *check* that the mprotect makes any 
difference, and maybe you have one of the early EM64T chips that didn't 
have NX support at all. Or maybe it's dodgy, and is actually the whole 
*reason* for the page fault problem..

I don't have any P4's capable of 64-bit operation (nor do I really want 
any ;)

		Linus

---
diff --git a/crashme.c b/crashme.c
index 5e7e663..19a2fbb 100644
--- a/crashme.c
+++ b/crashme.c
@@ -1,3 +1,5 @@
+#define pyr
+#define PAGSIZ 4096
 /* crashme: Create a string of random bytes and then jump to it.
             crashme [+]<nbytes>[.inc] <srand> <ntrys> [nsub] [verboseness] */
 
@@ -143,7 +145,6 @@ a script.
 #include <sys/mman.h>
 #include <sys/types.h>
 #include <sys/param.h>
-#include <sys/vmmac.h>
 #define strchr index
 #endif
 
@@ -215,7 +216,7 @@ unsigned char *bad_malloc(n)
 {unsigned char *data;
  data = (unsigned char *) malloc(n);
 #ifdef pyr
- if (mprotect(((int)data/PAGSIZ)*PAGSIZ, (n/PAGSIZ+1)*PAGSIZ,
+ if (mprotect(((long)data/PAGSIZ)*PAGSIZ, (n/PAGSIZ+1)*PAGSIZ,
 	      PROT_READ|PROT_WRITE|PROT_EXEC))
    perror("mprotect");
 #endif
@@ -259,11 +260,8 @@ void my_signal(sig, func)
  signal(sig, func);
 #else
  struct sigaction act;
+ memset(&act, 0, sizeof(act));
  act.sa_handler = func;
- act.sa_mask = 0;
-#ifdef linux
- act.sa_restorer = 0;
-#endif /* linux */
  act.sa_flags = SA_NOMASK;
 #ifdef SA_RESTART
  act.sa_flags |= SA_RESTART;
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
crashme fault, Randy Dunlap, (Thu Sep 13, 1:21 am)
Re: crashme fault, Andrea Arcangeli, (Sun Sep 16, 11:53 am)
Re: crashme fault, Randy Dunlap, (Sun Sep 16, 12:17 pm)
Re: crashme fault, Linus Torvalds, (Sat Sep 15, 12:28 am)
Re: crashme fault, Andi Kleen, (Sat Sep 15, 2:34 pm)
Re: crashme fault, Randy Dunlap, (Sat Sep 15, 2:40 pm)
Re: crashme fault, Linus Torvalds, (Sat Sep 15, 3:44 pm)
Re: crashme fault, Linus Torvalds, (Sat Sep 15, 6:15 pm)
Re: crashme fault, Linus Torvalds, (Sat Sep 15, 6:47 pm)
Re: crashme fault, Andi Kleen, (Sat Sep 15, 11:10 pm)
Re: crashme fault, Randy Dunlap, (Sat Sep 15, 7:47 pm)
Re: crashme fault, Linus Torvalds, (Sat Sep 15, 8:34 pm)
Re: crashme fault, Randy Dunlap, (Sun Sep 16, 12:40 pm)
Re: crashme fault, Linus Torvalds, (Sun Sep 16, 1:14 pm)
Re: crashme fault, Andi Kleen, (Sun Sep 16, 2:28 pm)
Re: crashme fault, Linus Torvalds, (Sun Sep 16, 2:12 pm)
Re: crashme fault, Randy Dunlap, (Mon Sep 17, 1:06 am)
Re: crashme fault, Linus Torvalds, (Mon Sep 17, 1:28 am)
Re: crashme fault, Randy Dunlap, (Mon Sep 17, 10:29 am)
Re: crashme fault, Linus Torvalds, (Mon Sep 17, 10:53 am)
Re: crashme fault, Randy Dunlap, (Mon Sep 17, 4:05 pm)
Re: crashme fault, Randy Dunlap, (Sat Sep 15, 3:53 pm)
Re: crashme fault, Randy Dunlap, (Sat Sep 15, 1:05 am)
Re: crashme fault, Randy Dunlap, (Sat Sep 15, 1:21 am)