diff options
author | Robert Morris <[email protected]> | 2021-08-06 11:06:24 -0400 |
---|---|---|
committer | Robert Morris <[email protected]> | 2021-08-06 11:06:24 -0400 |
commit | 3b3f83f10036391047a6e2fd3eb7b1a93aa05ed6 (patch) | |
tree | d9fd65829bf4d2300106b5a41afe116db53d6751 /user | |
parent | 08c9eda85fe68b8f311494d4cf78cfacda06868d (diff) | |
download | xv6-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
Diffstat (limited to 'user')
-rw-r--r-- | user/usertests.c | 25 |
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"}, |