aboutsummaryrefslogtreecommitdiffstats
path: root/executor
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-06-07 15:32:16 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-06-07 15:32:30 +0200
commit645e75f8038d1b177ead2d6ea0b3ade6f7f9d985 (patch)
treeabdb1ba3d8b7dff944d0ca84fc382bc0094f8635 /executor
parent7fb9023fd78f6c0641624e3169c405e384f14691 (diff)
executor: make syscall table and number constant
We see some crashes that suggest corruption of the syscall number: invalid command number 1296 (errno 11) invalid command number 107 (errno 110) Make the table and the number constant to prevent corruption.
Diffstat (limited to 'executor')
-rw-r--r--executor/common.h3
-rw-r--r--executor/executor.h6
-rw-r--r--executor/executor_akaros.cc6
-rw-r--r--executor/executor_bsd.cc6
-rw-r--r--executor/executor_fuchsia.cc6
-rw-r--r--executor/executor_linux.cc6
-rw-r--r--executor/executor_windows.cc6
-rw-r--r--executor/syscalls_akaros.h4
-rw-r--r--executor/syscalls_freebsd.h4
-rw-r--r--executor/syscalls_fuchsia.h8
-rw-r--r--executor/syscalls_linux.h20
-rw-r--r--executor/syscalls_netbsd.h4
-rw-r--r--executor/syscalls_test.h8
-rw-r--r--executor/syscalls_windows.h4
14 files changed, 44 insertions, 47 deletions
diff --git a/executor/common.h b/executor/common.h
index c1fcbae88..fe1290f73 100644
--- a/executor/common.h
+++ b/executor/common.h
@@ -69,9 +69,6 @@ struct call_t {
syscall_t call;
};
-// Defined in generated syscalls_OS.h files.
-extern call_t syscalls[];
-extern unsigned syscall_count;
#endif // #if defined(SYZ_EXECUTOR)
#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT)) || \
diff --git a/executor/executor.h b/executor/executor.h
index eb8474e4d..d5122cc71 100644
--- a/executor/executor.h
+++ b/executor/executor.h
@@ -165,7 +165,7 @@ struct kcov_comparison_t {
bool operator<(const struct kcov_comparison_t& other) const;
};
-long execute_syscall(call_t* c, long a0, long a1, long a2, long a3, long a4, long a5, long a6, long a7, long a8);
+long execute_syscall(const call_t* c, long a0, long a1, long a2, long a3, long a4, long a5, long a6, long a7, long a8);
thread_t* schedule_call(int call_index, int call_num, bool colliding, uint64 copyout_index, uint64 num_args, uint64* args, uint64* pos);
void handle_completion(thread_t* th);
void execute_call(thread_t* th);
@@ -393,7 +393,7 @@ retry:
}
// Normal syscall.
- if (call_num >= syscall_count)
+ if (call_num >= SYZ_SYSCALL_COUNT)
fail("invalid command number %llu", call_num);
uint64 copyout_index = read_input(&input_pos);
uint64 num_args = read_input(&input_pos);
@@ -634,7 +634,7 @@ void* worker_thread(void* arg)
void execute_call(thread_t* th)
{
event_reset(&th->ready);
- call_t* call = &syscalls[th->call_num];
+ const call_t* call = &syscalls[th->call_num];
debug("#%d: %s(", th->id, call->name);
for (int i = 0; i < th->num_args; i++) {
if (i != 0)
diff --git a/executor/executor_akaros.cc b/executor/executor_akaros.cc
index 4523b736a..1b690f2b9 100644
--- a/executor/executor_akaros.cc
+++ b/executor/executor_akaros.cc
@@ -8,10 +8,10 @@
#include "executor_posix.h"
-#include "executor.h"
-
#include "syscalls_akaros.h"
+#include "executor.h"
+
#include <sys/mman.h>
uint32 output;
@@ -74,7 +74,7 @@ int main(int argc, char** argv)
return 0;
}
-long execute_syscall(call_t* c, long a0, long a1, long a2, long a3, long a4, long a5, long a6, long a7, long a8)
+long execute_syscall(const call_t* c, long a0, long a1, long a2, long a3, long a4, long a5, long a6, long a7, long a8)
{
return syscall(c->sys_nr, a0, a1, a2, a3, a4, a5, a6, a7, a8);
}
diff --git a/executor/executor_bsd.cc b/executor/executor_bsd.cc
index 0e8767626..4ae2cf223 100644
--- a/executor/executor_bsd.cc
+++ b/executor/executor_bsd.cc
@@ -8,8 +8,6 @@
#include "executor_posix.h"
-#include "executor.h"
-
// This file is used by both freebsd and netbsd (as a link to executor_bsd.cc).
#if defined(__FreeBSD__)
#include "syscalls_freebsd.h"
@@ -21,6 +19,8 @@
#define __syscall syscall
#endif
+#include "executor.h"
+
#include <fcntl.h>
#include <signal.h>
#include <sys/ioctl.h>
@@ -144,7 +144,7 @@ int main(int argc, char** argv)
return 0;
}
-long execute_syscall(call_t* c, long a0, long a1, long a2, long a3, long a4, long a5, long a6, long a7, long a8)
+long execute_syscall(const call_t* c, long a0, long a1, long a2, long a3, long a4, long a5, long a6, long a7, long a8)
{
if (c->call)
return c->call(a0, a1, a2, a3, a4, a5, a6, a7, a8);
diff --git a/executor/executor_fuchsia.cc b/executor/executor_fuchsia.cc
index 08ac4e32f..6c7657732 100644
--- a/executor/executor_fuchsia.cc
+++ b/executor/executor_fuchsia.cc
@@ -8,10 +8,10 @@
#include "executor_posix.h"
-#include "executor.h"
-
#include "syscalls_fuchsia.h"
+#include "executor.h"
+
uint32 output;
int main(int argc, char** argv)
@@ -31,7 +31,7 @@ int main(int argc, char** argv)
return 0;
}
-long execute_syscall(call_t* c, long a0, long a1, long a2, long a3, long a4, long a5, long a6, long a7, long a8)
+long execute_syscall(const call_t* c, long a0, long a1, long a2, long a3, long a4, long a5, long a6, long a7, long a8)
{
long res = ZX_ERR_INVALID_ARGS;
NONFAILING(res = c->call(a0, a1, a2, a3, a4, a5, a6, a7, a8));
diff --git a/executor/executor_linux.cc b/executor/executor_linux.cc
index 4b88946dd..f0bccd949 100644
--- a/executor/executor_linux.cc
+++ b/executor/executor_linux.cc
@@ -21,10 +21,10 @@
#include "executor_linux.h"
-#include "executor.h"
-
#include "syscalls_linux.h"
+#include "executor.h"
+
#define KCOV_INIT_TRACE32 _IOR('c', 1, uint32)
#define KCOV_INIT_TRACE64 _IOR('c', 1, uint64)
#define KCOV_ENABLE _IO('c', 100)
@@ -124,7 +124,7 @@ int main(int argc, char** argv)
static __thread thread_t* current_thread;
-long execute_syscall(call_t* c, long a0, long a1, long a2, long a3, long a4, long a5, long a6, long a7, long a8)
+long execute_syscall(const call_t* c, long a0, long a1, long a2, long a3, long a4, long a5, long a6, long a7, long a8)
{
if (c->call)
return c->call(a0, a1, a2, a3, a4, a5, a6, a7, a8);
diff --git a/executor/executor_windows.cc b/executor/executor_windows.cc
index bb3848f33..a9ba5ea63 100644
--- a/executor/executor_windows.cc
+++ b/executor/executor_windows.cc
@@ -10,10 +10,10 @@
#include "executor_windows.h"
-#include "executor.h"
-
#include "syscalls_windows.h"
+#include "executor.h"
+
uint32 output;
int main(int argc, char** argv)
@@ -33,7 +33,7 @@ int main(int argc, char** argv)
return 0;
}
-long execute_syscall(call_t* c, long a0, long a1, long a2, long a3, long a4, long a5, long a6, long a7, long a8)
+long execute_syscall(const call_t* c, long a0, long a1, long a2, long a3, long a4, long a5, long a6, long a7, long a8)
{
__try {
return c->call(a0, a1, a2, a3, a4, a5, a6, a7, a8);
diff --git a/executor/syscalls_akaros.h b/executor/syscalls_akaros.h
index 40254b1d8..69ca4e481 100644
--- a/executor/syscalls_akaros.h
+++ b/executor/syscalls_akaros.h
@@ -6,8 +6,8 @@
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
-unsigned syscall_count = 35;
-call_t syscalls[] = {
+#define SYZ_SYSCALL_COUNT 35
+const call_t syscalls[] = {
{"abort_sysc_fd", 33},
{"chdir", 116},
{"close", 103},
diff --git a/executor/syscalls_freebsd.h b/executor/syscalls_freebsd.h
index 457dab275..e4ae4caa1 100644
--- a/executor/syscalls_freebsd.h
+++ b/executor/syscalls_freebsd.h
@@ -6,8 +6,8 @@
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
-unsigned syscall_count = 254;
-call_t syscalls[] = {
+#define SYZ_SYSCALL_COUNT 254
+const call_t syscalls[] = {
{"accept", 30},
{"accept$inet", 30},
{"accept$inet6", 30},
diff --git a/executor/syscalls_fuchsia.h b/executor/syscalls_fuchsia.h
index 205736e09..4f88c60b6 100644
--- a/executor/syscalls_fuchsia.h
+++ b/executor/syscalls_fuchsia.h
@@ -6,8 +6,8 @@
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
-unsigned syscall_count = 157;
-call_t syscalls[] = {
+#define SYZ_SYSCALL_COUNT 157
+const call_t syscalls[] = {
{"chdir", 0, (syscall_t)chdir},
{"chmod", 0, (syscall_t)chmod},
{"chown", 0, (syscall_t)chown},
@@ -175,8 +175,8 @@ call_t syscalls[] = {
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
-unsigned syscall_count = 157;
-call_t syscalls[] = {
+#define SYZ_SYSCALL_COUNT 157
+const call_t syscalls[] = {
{"chdir", 0, (syscall_t)chdir},
{"chmod", 0, (syscall_t)chmod},
{"chown", 0, (syscall_t)chown},
diff --git a/executor/syscalls_linux.h b/executor/syscalls_linux.h
index d093d0b6d..0d9bba2aa 100644
--- a/executor/syscalls_linux.h
+++ b/executor/syscalls_linux.h
@@ -6,8 +6,8 @@
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
-unsigned syscall_count = 1949;
-call_t syscalls[] = {
+#define SYZ_SYSCALL_COUNT 1949
+const call_t syscalls[] = {
{"accept4", 364},
{"accept4$alg", 364},
{"accept4$ax25", 364},
@@ -1967,8 +1967,8 @@ call_t syscalls[] = {
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
-unsigned syscall_count = 2001;
-call_t syscalls[] = {
+#define SYZ_SYSCALL_COUNT 2001
+const call_t syscalls[] = {
{"accept", 43},
{"accept$alg", 43},
{"accept$ax25", 43},
@@ -3980,8 +3980,8 @@ call_t syscalls[] = {
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
-unsigned syscall_count = 1958;
-call_t syscalls[] = {
+#define SYZ_SYSCALL_COUNT 1958
+const call_t syscalls[] = {
{"accept", 285},
{"accept$alg", 285},
{"accept$ax25", 285},
@@ -5950,8 +5950,8 @@ call_t syscalls[] = {
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
-unsigned syscall_count = 1930;
-call_t syscalls[] = {
+#define SYZ_SYSCALL_COUNT 1930
+const call_t syscalls[] = {
{"accept", 202},
{"accept$alg", 202},
{"accept$ax25", 202},
@@ -7892,8 +7892,8 @@ call_t syscalls[] = {
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
-unsigned syscall_count = 1819;
-call_t syscalls[] = {
+#define SYZ_SYSCALL_COUNT 1819
+const call_t syscalls[] = {
{"accept", 330},
{"accept$alg", 330},
{"accept$ax25", 330},
diff --git a/executor/syscalls_netbsd.h b/executor/syscalls_netbsd.h
index ca4bbad3d..7fac169d8 100644
--- a/executor/syscalls_netbsd.h
+++ b/executor/syscalls_netbsd.h
@@ -6,8 +6,8 @@
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
-unsigned syscall_count = 188;
-call_t syscalls[] = {
+#define SYZ_SYSCALL_COUNT 188
+const call_t syscalls[] = {
{"accept", 30},
{"accept$inet", 30},
{"accept$inet6", 30},
diff --git a/executor/syscalls_test.h b/executor/syscalls_test.h
index 715d402cf..2643a0db3 100644
--- a/executor/syscalls_test.h
+++ b/executor/syscalls_test.h
@@ -6,8 +6,8 @@
#define SYZ_PAGE_SIZE 8192
#define SYZ_NUM_PAGES 2048
#define SYZ_DATA_OFFSET 536870912
-unsigned syscall_count = 97;
-call_t syscalls[] = {
+#define SYZ_SYSCALL_COUNT 97
+const call_t syscalls[] = {
{"foo$any0", 0, (syscall_t)foo},
{"foo$anyres", 0, (syscall_t)foo},
{"mutate0", 0, (syscall_t)mutate0},
@@ -115,8 +115,8 @@ call_t syscalls[] = {
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
-unsigned syscall_count = 97;
-call_t syscalls[] = {
+#define SYZ_SYSCALL_COUNT 97
+const call_t syscalls[] = {
{"foo$any0", 0, (syscall_t)foo},
{"foo$anyres", 0, (syscall_t)foo},
{"mutate0", 0, (syscall_t)mutate0},
diff --git a/executor/syscalls_windows.h b/executor/syscalls_windows.h
index b20fe7266..1bb9af1b2 100644
--- a/executor/syscalls_windows.h
+++ b/executor/syscalls_windows.h
@@ -6,8 +6,8 @@
#define SYZ_PAGE_SIZE 4096
#define SYZ_NUM_PAGES 4096
#define SYZ_DATA_OFFSET 536870912
-unsigned syscall_count = 2955;
-call_t syscalls[] = {
+#define SYZ_SYSCALL_COUNT 2955
+const call_t syscalls[] = {
{"AbortDoc", 0, (syscall_t)AbortDoc},
{"AbortPath", 0, (syscall_t)AbortPath},
{"AbortPrinter", 0, (syscall_t)AbortPrinter},