aboutsummaryrefslogtreecommitdiffstats
path: root/executor/executor_windows.cc
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-10-16 12:18:50 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-10-16 14:21:54 +0200
commit85b1f93f8dbbc767c564e494a6353aa3517d5d49 (patch)
tree702d2318a2ddcf1a576294a6a4981c58abcfcf61 /executor/executor_windows.cc
parentf78642861b4dbe396a67d5e2a750e22f83f3edd5 (diff)
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.
Diffstat (limited to 'executor/executor_windows.cc')
-rw-r--r--executor/executor_windows.cc29
1 files changed, 4 insertions, 25 deletions
diff --git a/executor/executor_windows.cc b/executor/executor_windows.cc
index 862621951..0124aa0d9 100644
--- a/executor/executor_windows.cc
+++ b/executor/executor_windows.cc
@@ -14,39 +14,18 @@
#include "syscalls_windows.h"
-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;
}
- 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;
}