summaryrefslogtreecommitdiff
path: root/user
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2019-09-21 04:54:25 -0400
committerRobert Morris <[email protected]>2019-09-21 04:54:25 -0400
commitd940fd122d8e04dfc1122ca6b224703eead55f66 (patch)
treeae2e6a5f2d10a6bd43532370d4c0ff70353b7a19 /user
parent6b79ee69b799c03f939c2ffc52c30d2bcdf7f2ef (diff)
downloadxv6-labs-d940fd122d8e04dfc1122ca6b224703eead55f66.tar.gz
xv6-labs-d940fd122d8e04dfc1122ca6b224703eead55f66.tar.bz2
xv6-labs-d940fd122d8e04dfc1122ca6b224703eead55f66.zip
don't leak memory if exec() arguments are invalid.
Diffstat (limited to 'user')
-rw-r--r--user/usertests.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/user/usertests.c b/user/usertests.c
index d2076c7..af3e5db 100644
--- a/user/usertests.c
+++ b/user/usertests.c
@@ -2016,6 +2016,7 @@ sbrkbugs(char *s)
// has this bug, it will panic: balloc: out of blocks.
// assumed_free may need to be raised to be
// more than the number of free blocks.
+// this test takes a long time.
void
badwrite(char *s)
{
@@ -2048,6 +2049,22 @@ badwrite(char *s)
exit(0);
}
+// test whether exec() leaks memory if one of the
+// arguments is invalid. the test passes if
+// the kernel doesn't panic.
+void
+badarg(char *s)
+{
+ for(int i = 0; i < 50000; i++){
+ char *argv[2];
+ argv[0] = (char*)0xffffffff;
+ argv[1] = 0;
+ exec("echo", argv);
+ }
+
+ exit(0);
+}
+
// run each test in its own process. run returns 1 if child's exit()
// indicates success.
int
@@ -2087,7 +2104,8 @@ main(int argc, char *argv[])
} tests[] = {
{pgbug, "pgbug" },
{sbrkbugs, "sbrkbugs" },
- {badwrite, "badwrite" },
+ // {badwrite, "badwrite" },
+ {badarg, "badarg" },
{reparent, "reparent" },
{twochildren, "twochildren"},
{forkfork, "forkfork"},