added bad-jump/read/write bad-jump2/read2/write2 to check that process
authorGodmar Back <godmar@gmail.com>
Wed, 7 Jun 2006 22:09:19 +0000 (22:09 +0000)
committerGodmar Back <godmar@gmail.com>
Wed, 7 Jun 2006 22:09:19 +0000 (22:09 +0000)
that attempt to execute/read/write NULL or a kernel address, resp., are
properly terminated.

14 files changed:
src/tests/userprog/Make.tests
src/tests/userprog/Rubric.robustness
src/tests/userprog/bad-jump.c [new file with mode: 0644]
src/tests/userprog/bad-jump.ck [new file with mode: 0644]
src/tests/userprog/bad-jump2.c [new file with mode: 0644]
src/tests/userprog/bad-jump2.ck [new file with mode: 0644]
src/tests/userprog/bad-read.c [new file with mode: 0644]
src/tests/userprog/bad-read.ck [new file with mode: 0644]
src/tests/userprog/bad-read2.c [new file with mode: 0644]
src/tests/userprog/bad-read2.ck [new file with mode: 0644]
src/tests/userprog/bad-write.c [new file with mode: 0644]
src/tests/userprog/bad-write.ck [new file with mode: 0644]
src/tests/userprog/bad-write2.c [new file with mode: 0644]
src/tests/userprog/bad-write2.ck [new file with mode: 0644]

index 9a5869f51e8b32643f9f4bcd564ab55078ba2498..8d64c056c9642cb07bfdabe96843b7f3ea61d640 100644 (file)
@@ -14,7 +14,8 @@ read-zero read-stdout read-bad-fd write-normal write-bad-ptr          \
 write-boundary write-zero write-stdin write-bad-fd exec-once exec-arg  \
 exec-multiple exec-missing exec-bad-ptr wait-simple wait-twice         \
 wait-killed wait-bad-pid multi-recurse multi-child-fd rox-simple       \
-rox-child rox-multichild)
+rox-child rox-multichild bad-read bad-write bad-read2 bad-write2        \
+bad-jump bad-jump2)
 
 tests/userprog_PROGS = $(tests/userprog_TESTS) $(addprefix \
 tests/userprog/,child-simple child-args child-bad child-close child-rox)
@@ -26,6 +27,12 @@ tests/userprog/args-many_SRC = tests/userprog/args.c
 tests/userprog/args-dbl-space_SRC = tests/userprog/args.c
 tests/userprog/sc-bad-sp_SRC = tests/userprog/sc-bad-sp.c tests/main.c
 tests/userprog/sc-bad-arg_SRC = tests/userprog/sc-bad-arg.c tests/main.c
+tests/userprog/bad-read_SRC = tests/userprog/bad-read.c tests/main.c
+tests/userprog/bad-write_SRC = tests/userprog/bad-write.c tests/main.c
+tests/userprog/bad-jump_SRC = tests/userprog/bad-jump.c tests/main.c
+tests/userprog/bad-read2_SRC = tests/userprog/bad-read2.c tests/main.c
+tests/userprog/bad-write2_SRC = tests/userprog/bad-write2.c tests/main.c
+tests/userprog/bad-jump2_SRC = tests/userprog/bad-jump2.c tests/main.c
 tests/userprog/sc-boundary_SRC = tests/userprog/sc-boundary.c  \
 tests/userprog/boundary.c tests/main.c
 tests/userprog/sc-boundary-2_SRC = tests/userprog/sc-boundary-2.c      \
index 0a5690a5e640aa02085208dc7282fbfff2ba462a..569615687fec0f24710661455b21ee56f879002e 100644 (file)
@@ -39,3 +39,10 @@ Robustness of system calls:
 5      wait-bad-pid
 5      wait-killed
 
+- Test robustness of exception handling.
+1      bad-read
+1      bad-write
+1      bad-jump
+1      bad-read2
+1      bad-write2
+1      bad-jump2
diff --git a/src/tests/userprog/bad-jump.c b/src/tests/userprog/bad-jump.c
new file mode 100644 (file)
index 0000000..51b7c9f
--- /dev/null
@@ -0,0 +1,13 @@
+/* This program attempts to execute code at address 0, which is not mapped.
+   This should terminate the process with a -1 exit code. */
+
+#include "tests/lib.h"
+#include "tests/main.h"
+
+void
+test_main (void) 
+{
+  msg ("Congratulations - you have successfully called NULL: %d", 
+        ((int (*)(void))NULL)());
+  fail ("should have exited with -1");
+}
diff --git a/src/tests/userprog/bad-jump.ck b/src/tests/userprog/bad-jump.ck
new file mode 100644 (file)
index 0000000..71662e8
--- /dev/null
@@ -0,0 +1,8 @@
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_expected ([<<'EOF']);
+(bad-jump) begin
+bad-jump: exit(-1)
+EOF
diff --git a/src/tests/userprog/bad-jump2.c b/src/tests/userprog/bad-jump2.c
new file mode 100644 (file)
index 0000000..dc7c2a7
--- /dev/null
@@ -0,0 +1,13 @@
+/* This program attempts to execute code at a kernel virtual address. 
+   This should terminate the process with a -1 exit code. */
+
+#include "tests/lib.h"
+#include "tests/main.h"
+
+void
+test_main (void) 
+{
+  msg ("Congratulations - you have successfully called kernel code: %d", 
+        ((int (*)(void))0xC0000000)());
+  fail ("should have exited with -1");
+}
diff --git a/src/tests/userprog/bad-jump2.ck b/src/tests/userprog/bad-jump2.ck
new file mode 100644 (file)
index 0000000..8226115
--- /dev/null
@@ -0,0 +1,8 @@
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_expected ([<<'EOF']);
+(bad-jump2) begin
+bad-jump2: exit(-1)
+EOF
diff --git a/src/tests/userprog/bad-read.c b/src/tests/userprog/bad-read.c
new file mode 100644 (file)
index 0000000..904c278
--- /dev/null
@@ -0,0 +1,13 @@
+/* This program attempts to read memory at an address that is not mapped.
+   This should terminate the process with a -1 exit code. */
+
+#include "tests/lib.h"
+#include "tests/main.h"
+
+void
+test_main (void) 
+{
+  msg ("Congratulations - you have successfully dereferenced NULL: %d", 
+        *(int *)NULL);
+  fail ("should have exited with -1");
+}
diff --git a/src/tests/userprog/bad-read.ck b/src/tests/userprog/bad-read.ck
new file mode 100644 (file)
index 0000000..8a531d9
--- /dev/null
@@ -0,0 +1,8 @@
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_expected ([<<'EOF']);
+(bad-read) begin
+bad-read: exit(-1)
+EOF
diff --git a/src/tests/userprog/bad-read2.c b/src/tests/userprog/bad-read2.c
new file mode 100644 (file)
index 0000000..a2fc237
--- /dev/null
@@ -0,0 +1,13 @@
+/* This program attempts to read kernel memory. 
+   This should terminate the process with a -1 exit code. */
+
+#include "tests/lib.h"
+#include "tests/main.h"
+
+void
+test_main (void) 
+{
+  msg ("Congratulations - you have successfully read kernel memory: %d", 
+        *(int *)0xC0000000);
+  fail ("should have exited with -1");
+}
diff --git a/src/tests/userprog/bad-read2.ck b/src/tests/userprog/bad-read2.ck
new file mode 100644 (file)
index 0000000..cabe862
--- /dev/null
@@ -0,0 +1,8 @@
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_expected ([<<'EOF']);
+(bad-read2) begin
+bad-read2: exit(-1)
+EOF
diff --git a/src/tests/userprog/bad-write.c b/src/tests/userprog/bad-write.c
new file mode 100644 (file)
index 0000000..000c26b
--- /dev/null
@@ -0,0 +1,12 @@
+/* This program attempts to write to memory at an address that is not mapped.
+   This should terminate the process with a -1 exit code. */
+
+#include "tests/lib.h"
+#include "tests/main.h"
+
+void
+test_main (void) 
+{
+  *(int *)NULL = 42;
+  fail ("should have exited with -1");
+}
diff --git a/src/tests/userprog/bad-write.ck b/src/tests/userprog/bad-write.ck
new file mode 100644 (file)
index 0000000..7b2e2d7
--- /dev/null
@@ -0,0 +1,8 @@
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_expected ([<<'EOF']);
+(bad-write) begin
+bad-write: exit(-1)
+EOF
diff --git a/src/tests/userprog/bad-write2.c b/src/tests/userprog/bad-write2.c
new file mode 100644 (file)
index 0000000..753da1e
--- /dev/null
@@ -0,0 +1,12 @@
+/* This program attempts to write to kernel memory. 
+   This should terminate the process with a -1 exit code. */
+
+#include "tests/lib.h"
+#include "tests/main.h"
+
+void
+test_main (void) 
+{
+  *(int *)0xC0000000 = 42;
+  fail ("should have exited with -1");
+}
diff --git a/src/tests/userprog/bad-write2.ck b/src/tests/userprog/bad-write2.ck
new file mode 100644 (file)
index 0000000..c94a10f
--- /dev/null
@@ -0,0 +1,8 @@
+# -*- perl -*-
+use strict;
+use warnings;
+use tests::tests;
+check_expected ([<<'EOF']);
+(bad-write2) begin
+bad-write2: exit(-1)
+EOF