aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common_fuchsia.h
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-09-22 11:09:53 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-09-22 13:10:55 +0200
commit913d592f973a0155647473eaa032711fe956f8a5 (patch)
tree29b1b2083c00d199cf4d9a30917411d923b49ef4 /executor/common_fuchsia.h
parentc26ea367cfa790e86800ac025638ad50f95b8287 (diff)
all: more assorted fuchsia support
Diffstat (limited to 'executor/common_fuchsia.h')
-rw-r--r--executor/common_fuchsia.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/executor/common_fuchsia.h b/executor/common_fuchsia.h
new file mode 100644
index 000000000..189e7bc3c
--- /dev/null
+++ b/executor/common_fuchsia.h
@@ -0,0 +1,51 @@
+// Copyright 2017 syzkaller project authors. All rights reserved.
+// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+// This file is shared between executor and csource package.
+
+#include <zircon/process.h>
+#include <zircon/syscalls.h>
+
+#define doexit exit
+
+#include "common.h"
+
+#if defined(SYZ_EXECUTOR) || defined(SYZ_HANDLE_SEGV)
+static void install_segv_handler()
+{
+ struct sigaction sa;
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_sigaction = segv_handler;
+ sa.sa_flags = SA_NODEFER | SA_SIGINFO;
+ sigaction(SIGSEGV, &sa, NULL);
+ sigaction(SIGBUS, &sa, NULL);
+}
+#endif
+
+#if defined(SYZ_EXECUTOR) || defined(SYZ_FAULT_INJECTION)
+static int inject_fault(int nth)
+{
+ return 0;
+}
+
+static int fault_injected(int fail_fd)
+{
+ return 0;
+}
+#endif
+
+#if defined(SYZ_EXECUTOR) || defined(__NR_syz_mmap)
+long syz_mmap(size_t addr, size_t size)
+{
+ zx_handle_t mapping = 0;
+ uintptr_t res = 0;
+ uintptr_t offset = 16 << 20;
+ zx_status_t status = zx_vmar_allocate(zx_vmar_root_self(), addr - offset, size,
+ ZX_VM_FLAG_SPECIFIC | ZX_VM_FLAG_CAN_MAP_READ | ZX_VM_FLAG_CAN_MAP_WRITE,
+ &mapping, &res);
+ if (addr != res)
+ error("zx_vmar_allocate allocated wrong address: %p, want %p", (void*)res, (void*)addr);
+ return status;
+}
+#endif