From 913d592f973a0155647473eaa032711fe956f8a5 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 22 Sep 2017 11:09:53 +0200 Subject: all: more assorted fuchsia support --- executor/common_fuchsia.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 executor/common_fuchsia.h (limited to 'executor/common_fuchsia.h') 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 +#include + +#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 -- cgit mrf-deployment