aboutsummaryrefslogtreecommitdiffstats
path: root/executor
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-08-03 19:48:30 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-08-03 19:53:14 +0200
commit78e3ad98f6120342ae56b9812c695637fc245c75 (patch)
tree47b2d2f40d053d755c07f937b53daea99c282991 /executor
parent5ba57bfe16056e7657e29ca6e5ef5b1446f8fce6 (diff)
sys/test: add more tests
Add syz_errno syscall which sets errno to the argument, and add a test with different errno values. This mostly tests the testing infrastructure itself. Add syz_compare syscall which compare two blobs, this can be used for testing of argument memory layout. Implement syz_mmap and fix Makefile to allow building syz-execprog for test OS. Useful for debugging. Update #603
Diffstat (limited to 'executor')
-rw-r--r--executor/common_test.h35
-rw-r--r--executor/defs.h8
-rw-r--r--executor/syscalls.h8
3 files changed, 47 insertions, 4 deletions
diff --git a/executor/common_test.h b/executor/common_test.h
index 78b3f8e22..75ec81721 100644
--- a/executor/common_test.h
+++ b/executor/common_test.h
@@ -7,8 +7,43 @@
#include <unistd.h>
#if SYZ_EXECUTOR || __NR_syz_mmap
+#include <sys/mman.h>
+
+// syz_mmap(addr vma, len len[addr])
static long syz_mmap(long a0, long a1)
{
+ return (long)mmap((void*)a0, a1, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0);
+}
+#endif
+
+#if SYZ_EXECUTOR || __NR_syz_errno
+#include <errno.h>
+
+// syz_errno(v int32)
+static long syz_errno(long v)
+{
+ errno = v;
+ return v == 0 ? 0 : -1;
+}
+#endif
+
+#if SYZ_EXECUTOR || __NR_syz_compare
+#include <errno.h>
+#include <string.h>
+
+// syz_compare(want ptr[in, string], want_len len[want], got ptr[in, compare_data], got_len len[got])
+static long syz_compare(long want, long want_len, long got, long got_len)
+{
+ if (want_len != got_len) {
+ debug("syz_compare: want_len=%lu got_len=%lu\n", want_len, got_len);
+ errno = EBADF;
+ return -1;
+ }
+ if (memcmp((void*)want, (void*)got, want_len)) {
+ debug("syz_compare: data differs\n");
+ errno = EINVAL;
+ return -1;
+ }
return 0;
}
#endif
diff --git a/executor/defs.h b/executor/defs.h
index bd92a80b2..eb73e512d 100644
--- a/executor/defs.h
+++ b/executor/defs.h
@@ -130,7 +130,7 @@
#if GOARCH_32_fork_shmem
#define GOARCH "32_fork_shmem"
-#define SYZ_REVISION "18f983f4760ca5ac41eaf7c18bd9f487f6dde42b"
+#define SYZ_REVISION "d09983a8bb4f2ccd0e303191862d170b5b636bd8"
#define SYZ_EXECUTOR_USES_FORK_SERVER 1
#define SYZ_EXECUTOR_USES_SHMEM 1
#define SYZ_PAGE_SIZE 4096
@@ -140,7 +140,7 @@
#if GOARCH_32_shmem
#define GOARCH "32_shmem"
-#define SYZ_REVISION "9d4e8ff9d9c38d5fe7cdc046adcde8be29782e6b"
+#define SYZ_REVISION "8d0f255b4d310c70d0e7d65ac8e5c6c3032a9e14"
#define SYZ_EXECUTOR_USES_FORK_SERVER 0
#define SYZ_EXECUTOR_USES_SHMEM 1
#define SYZ_PAGE_SIZE 8192
@@ -150,7 +150,7 @@
#if GOARCH_64
#define GOARCH "64"
-#define SYZ_REVISION "981444b6842c8896801fdf67dc75c454cad9e594"
+#define SYZ_REVISION "285bb68296c57fc93062731e5c0ecfbfc105d685"
#define SYZ_EXECUTOR_USES_FORK_SERVER 0
#define SYZ_EXECUTOR_USES_SHMEM 0
#define SYZ_PAGE_SIZE 4096
@@ -160,7 +160,7 @@
#if GOARCH_64_fork
#define GOARCH "64_fork"
-#define SYZ_REVISION "1c9fe1f1a1f6f871fc5c088ca80174655322aca4"
+#define SYZ_REVISION "39c2288dd1c825ce7a587f946cfc91e0e453cf5e"
#define SYZ_EXECUTOR_USES_FORK_SERVER 1
#define SYZ_EXECUTOR_USES_SHMEM 0
#define SYZ_PAGE_SIZE 8192
diff --git a/executor/syscalls.h b/executor/syscalls.h
index a8845adb5..6f53b4490 100644
--- a/executor/syscalls.h
+++ b/executor/syscalls.h
@@ -11439,6 +11439,8 @@ const call_t syscalls[] = {
#if GOARCH_32_fork_shmem
const call_t syscalls[] = {
+ {"syz_compare", 0, (syscall_t)syz_compare},
+ {"syz_errno", 0, (syscall_t)syz_errno},
{"syz_mmap", 0, (syscall_t)syz_mmap},
};
@@ -11446,6 +11448,8 @@ const call_t syscalls[] = {
#if GOARCH_32_shmem
const call_t syscalls[] = {
+ {"syz_compare", 0, (syscall_t)syz_compare},
+ {"syz_errno", 0, (syscall_t)syz_errno},
{"syz_mmap", 0, (syscall_t)syz_mmap},
};
@@ -11472,6 +11476,8 @@ const call_t syscalls[] = {
{"mutate8", 0},
{"serialize0", 0},
{"serialize1", 0},
+ {"syz_compare", 0, (syscall_t)syz_compare},
+ {"syz_errno", 0, (syscall_t)syz_errno},
{"syz_mmap", 0, (syscall_t)syz_mmap},
{"test", 0},
{"test$align0", 0},
@@ -11566,6 +11572,8 @@ const call_t syscalls[] = {
#if GOARCH_64_fork
const call_t syscalls[] = {
+ {"syz_compare", 0, (syscall_t)syz_compare},
+ {"syz_errno", 0, (syscall_t)syz_errno},
{"syz_mmap", 0, (syscall_t)syz_mmap},
};