summaryrefslogtreecommitdiff
path: root/usertests.c
diff options
context:
space:
mode:
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.c24
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();