From 85b1f93f8dbbc767c564e494a6353aa3517d5d49 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 16 Oct 2017 12:18:50 +0200 Subject: executor, pkg/ipc: unify ipc protocol between linux and other OSes We currently use more complex and functional protocol on linux, and a simple ad-hoc protocol on other OSes. This leads to code duplication in both ipc and executor. Linux supports coverage, shared memory communication and fork server, which would also be useful for most other OSes. Unify communication protocol and parametrize it by (1) use of shmem or only pipes, (2) use of fork server. This reduces duplication in ipc and executor and will allow to support the useful features for other OSes easily. Finally, this fixes akaros support as it currently uses syz-stress running on host (linux) and executor running on akaros. --- executor/executor_freebsd.cc | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) (limited to 'executor/executor_freebsd.cc') diff --git a/executor/executor_freebsd.cc b/executor/executor_freebsd.cc index 8435d4465..abfb4139b 100644 --- a/executor/executor_freebsd.cc +++ b/executor/executor_freebsd.cc @@ -16,13 +16,12 @@ #include #include -char input_data[kMaxInput]; uint32_t output; int main(int argc, char** argv) { if (argc == 2 && strcmp(argv[1], "version") == 0) { - puts("linux " GOARCH " " SYZ_REVISION " " GIT_REVISION); + puts(GOOS " " GOARCH " " SYZ_REVISION " " GIT_REVISION); return 0; } @@ -40,29 +39,9 @@ int main(int argc, char** argv) setrlimit(RLIMIT_CORE, &rlim); install_segv_handler(); - int pos = 0; - for (;;) { - int rv = read(0, input_data + pos, sizeof(input_data) - pos); - if (rv < 0) - fail("read failed"); - if (rv == 0) - break; - pos += rv; - } - if (pos < 24) - fail("truncated input"); - - uint64_t flags = *(uint64_t*)input_data; - flag_debug = flags & (1 << 0); - flag_threaded = flags & (1 << 2); - flag_collide = flags & (1 << 3); - if (!flag_threaded) - flag_collide = false; - uint64_t executor_pid = *((uint64_t*)input_data + 2); - debug("input %d, threaded=%d collide=%d pid=%llu\n", - pos, flag_threaded, flag_collide, executor_pid); - - execute_one(((uint64_t*)input_data) + 3); + setup_control_pipes(); + receive_execute(); + execute_one(); return 0; } -- cgit mrf-deployment