summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--user/usertests.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/user/usertests.c b/user/usertests.c
index 85a54d2..7d53099 100644
--- a/user/usertests.c
+++ b/user/usertests.c
@@ -2228,6 +2228,30 @@ kernmem(char *s)
}
}
+// user code should not be able to write to addresses above MAXVA.
+void
+MAXVAplus(char *s)
+{
+ volatile uint64 a = MAXVA;
+ for( ; a != 0; a <<= 1){
+ int pid;
+ pid = fork();
+ if(pid < 0){
+ printf("%s: fork failed\n", s);
+ exit(1);
+ }
+ if(pid == 0){
+ *(char*)a = 99;
+ printf("%s: oops wrote %x\n", s, a);
+ exit(1);
+ }
+ int xstatus;
+ wait(&xstatus);
+ if(xstatus != -1) // did kernel kill child?
+ exit(1);
+ }
+}
+
// if we run the system out of memory, does it clean up the last
// failed allocation?
void
@@ -2802,6 +2826,7 @@ main(int argc, char *argv[])
void (*f)(char *);
char *s;
} tests[] = {
+ {MAXVAplus, "MAXVAplus"},
{manywrites, "manywrites"},
{execout, "execout"},
{copyin, "copyin"},