aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'executor/common.h')
-rw-r--r--executor/common.h67
1 files changed, 4 insertions, 63 deletions
diff --git a/executor/common.h b/executor/common.h
index 9eb5ea2c5..f5b525cc4 100644
--- a/executor/common.h
+++ b/executor/common.h
@@ -5,10 +5,6 @@
#include <stdint.h>
#include <string.h>
-#if defined(SYZ_EXECUTOR) || defined(SYZ_THREADED) || defined(SYZ_COLLIDE)
-#include <pthread.h>
-#include <stdlib.h>
-#endif
#if defined(SYZ_EXECUTOR) || defined(SYZ_USE_TMP_DIR)
#include <errno.h>
#include <stdarg.h>
@@ -21,15 +17,6 @@
#include <signal.h>
#include <string.h>
#endif
-#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT))
-#include <errno.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <time.h>
-#endif
#if defined(SYZ_EXECUTOR) || defined(SYZ_DEBUG)
#include <stdarg.h>
#include <stdio.h>
@@ -64,7 +51,7 @@ const int kErrorStatus = 68;
defined(SYZ_USE_TMP_DIR) || defined(SYZ_TUN_ENABLE) || defined(SYZ_SANDBOX_NAMESPACE) || \
defined(SYZ_SANDBOX_SETUID) || defined(SYZ_FAULT_INJECTION) || defined(__NR_syz_kvm_setup_cpu)
// logical error (e.g. invalid input program), use as an assert() alernative
-__attribute__((noreturn)) static void fail(const char* msg, ...)
+NORETURN static void fail(const char* msg, ...)
{
int e = errno;
fflush(stdout);
@@ -81,7 +68,7 @@ __attribute__((noreturn)) static void fail(const char* msg, ...)
#if defined(SYZ_EXECUTOR)
// kernel error (e.g. wrong syscall return value)
-__attribute__((noreturn)) static void error(const char* msg, ...)
+NORETURN static void error(const char* msg, ...)
{
fflush(stdout);
va_list args;
@@ -95,7 +82,7 @@ __attribute__((noreturn)) static void error(const char* msg, ...)
#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT))
// just exit (e.g. due to temporal ENOMEM error)
-__attribute__((noreturn)) static void exitf(const char* msg, ...)
+NORETURN static void exitf(const char* msg, ...)
{
int e = errno;
fflush(stdout);
@@ -139,41 +126,6 @@ static void debug(const char* msg, ...)
}
#endif
-#if defined(SYZ_EXECUTOR) || defined(SYZ_HANDLE_SEGV)
-static __thread int skip_segv;
-static __thread jmp_buf segv_env;
-
-static void segv_handler(int sig, siginfo_t* info, void* uctx)
-{
- // Generated programs can contain bad (unmapped/protected) addresses,
- // which cause SIGSEGVs during copyin/copyout.
- // This handler ignores such crashes to allow the program to proceed.
- // We additionally opportunistically check that the faulty address
- // is not within executable data region, because such accesses can corrupt
- // output region and then fuzzer will fail on corrupted data.
- uintptr_t addr = (uintptr_t)info->si_addr;
- const uintptr_t prog_start = 1 << 20;
- const uintptr_t prog_end = 100 << 20;
- if (__atomic_load_n(&skip_segv, __ATOMIC_RELAXED) && (addr < prog_start || addr > prog_end)) {
- debug("SIGSEGV on %p, skipping\n", addr);
- _longjmp(segv_env, 1);
- }
- debug("SIGSEGV on %p, exiting\n", addr);
- doexit(sig);
- for (;;) {
- }
-}
-
-#define NONFAILING(...) \
- { \
- __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \
- if (_setjmp(segv_env) == 0) { \
- __VA_ARGS__; \
- } \
- __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \
- }
-#endif
-
#if defined(SYZ_EXECUTOR) || defined(SYZ_USE_CHECKSUMS)
struct csum_inet {
uint32_t acc;
@@ -204,15 +156,4 @@ static uint16_t csum_inet_digest(struct csum_inet* csum)
{
return ~csum->acc;
}
-#endif
-
-#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT))
-static uint64_t current_time_ms()
-{
- struct timespec ts;
-
- if (clock_gettime(CLOCK_MONOTONIC, &ts))
- fail("clock_gettime failed");
- return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
-}
-#endif
+#endif \ No newline at end of file