summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2021-08-06 11:06:24 -0400
committerRobert Morris <[email protected]>2021-08-06 11:06:24 -0400
commit3b3f83f10036391047a6e2fd3eb7b1a93aa05ed6 (patch)
treed9fd65829bf4d2300106b5a41afe116db53d6751
parent08c9eda85fe68b8f311494d4cf78cfacda06868d (diff)
downloadxv6-labs-3b3f83f10036391047a6e2fd3eb7b1a93aa05ed6.tar.gz
xv6-labs-3b3f83f10036391047a6e2fd3eb7b1a93aa05ed6.tar.bz2
xv6-labs-3b3f83f10036391047a6e2fd3eb7b1a93aa05ed6.zip
check that there's no panic if user process tries to write >= MAXVA
-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"},