diff options
author | Robert Morris <rtm@nephron.lcs.mit.edu> | 2010-08-06 11:12:18 -0400 |
---|---|---|
committer | Robert Morris <rtm@nephron.lcs.mit.edu> | 2010-08-06 11:12:18 -0400 |
commit | c4cc10da7ef6d65f0f654445e0af35b8309f16c2 (patch) | |
tree | 771c4791115f945fc86ea9eadc350bb22c518535 /usertests.c | |
parent | 1afc9d3fcaa7c5992659bb8b69f639b746dda2bc (diff) | |
download | xv6-labs-c4cc10da7ef6d65f0f654445e0af35b8309f16c2.tar.gz xv6-labs-c4cc10da7ef6d65f0f654445e0af35b8309f16c2.tar.bz2 xv6-labs-c4cc10da7ef6d65f0f654445e0af35b8309f16c2.zip |
fix corner cases in exec of ELF
put an invalid page below the stack
have fork() handle invalid pages
Diffstat (limited to 'usertests.c')
-rw-r--r-- | usertests.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/usertests.c b/usertests.c index 2bd21ba..247cc95 100644 --- a/usertests.c +++ b/usertests.c @@ -1261,6 +1261,29 @@ sbrktest(void) printf(stdout, "sbrk test OK\n"); } +void +stacktest(void) +{ + printf(stdout, "stack test\n"); + char dummy = 1; + char *p = &dummy; + int ppid = getpid(); + int pid = fork(); + if(pid < 0){ + printf(stdout, "fork failed\n"); + exit(); + } + if(pid == 0){ + // should cause a trap: + p[-4096] = 'z'; + kill(ppid); + printf(stdout, "stack test failed: page before stack was writeable\n"); + exit(); + } + wait(); + printf(stdout, "stack test OK\n"); +} + int main(int argc, char *argv[]) { @@ -1272,6 +1295,7 @@ main(int argc, char *argv[]) } close(open("usertests.ran", O_CREATE)); + stacktest(); sbrktest(); opentest(); |