From 3704c60135f96c02079274dad1a00b2dc3f846c9 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 19 Oct 2017 11:06:05 +0200 Subject: executor: fix build breakages due to doexit Some standard libraries contain "using ::exit;", which breaks with the current redefinition of exit. --- executor/common.h | 8 ++++++++ executor/common_akaros.h | 12 +++++++++++- executor/common_freebsd.h | 12 +++++++++++- executor/common_fuchsia.h | 5 +++++ executor/common_linux.h | 6 ------ executor/common_windows.h | 12 +++++++++++- 6 files changed, 46 insertions(+), 9 deletions(-) (limited to 'executor') diff --git a/executor/common.h b/executor/common.h index 980ea74b7..b7a0706fd 100644 --- a/executor/common.h +++ b/executor/common.h @@ -22,6 +22,14 @@ #include #endif +#if defined(SYZ_EXECUTOR) +// exit/_exit do not necessary work (e.g. if fuzzer sets seccomp filter that prohibits exit_group). +// Use doexit instead. We must redefine exit to something that exists in stdlib, +// because some standard libraries contain "using ::exit;", but has different signature. +#define exit vsnprintf +#define _exit vsnprintf +#endif + #if defined(SYZ_EXECUTOR) #if defined(__GNUC__) #define SYSCALLAPI diff --git a/executor/common_akaros.h b/executor/common_akaros.h index 1cccfbc96..9ae6538af 100644 --- a/executor/common_akaros.h +++ b/executor/common_akaros.h @@ -30,7 +30,17 @@ #include #endif -#define doexit exit +#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT)) || \ + defined(SYZ_USE_TMP_DIR) || defined(SYZ_HANDLE_SEGV) || defined(SYZ_TUN_ENABLE) || \ + defined(SYZ_SANDBOX_NAMESPACE) || defined(SYZ_SANDBOX_SETUID) || \ + defined(SYZ_SANDBOX_NONE) || defined(SYZ_FAULT_INJECTION) || defined(__NR_syz_kvm_setup_cpu) +__attribute__((noreturn)) static void doexit(int status) +{ + _exit(status); + for (;;) { + } +} +#endif #include "common.h" diff --git a/executor/common_freebsd.h b/executor/common_freebsd.h index 0712942bd..a9c4933db 100644 --- a/executor/common_freebsd.h +++ b/executor/common_freebsd.h @@ -21,7 +21,17 @@ #include #endif -#define doexit exit +#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT)) || \ + defined(SYZ_USE_TMP_DIR) || defined(SYZ_HANDLE_SEGV) || defined(SYZ_TUN_ENABLE) || \ + defined(SYZ_SANDBOX_NAMESPACE) || defined(SYZ_SANDBOX_SETUID) || \ + defined(SYZ_SANDBOX_NONE) || defined(SYZ_FAULT_INJECTION) || defined(__NR_syz_kvm_setup_cpu) +__attribute__((noreturn)) static void doexit(int status) +{ + _exit(status); + for (;;) { + } +} +#endif #include "common.h" diff --git a/executor/common_fuchsia.h b/executor/common_fuchsia.h index f3889daec..fc1470c01 100644 --- a/executor/common_fuchsia.h +++ b/executor/common_fuchsia.h @@ -33,12 +33,17 @@ #include #endif +#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT)) || \ + defined(SYZ_USE_TMP_DIR) || defined(SYZ_HANDLE_SEGV) || defined(SYZ_TUN_ENABLE) || \ + defined(SYZ_SANDBOX_NAMESPACE) || defined(SYZ_SANDBOX_SETUID) || \ + defined(SYZ_SANDBOX_NONE) || defined(SYZ_FAULT_INJECTION) || defined(__NR_syz_kvm_setup_cpu) __attribute__((noreturn)) static void doexit(int status) { _exit(status); for (;;) { } } +#endif #include "common.h" diff --git a/executor/common_linux.h b/executor/common_linux.h index 8b9c00bfd..48c23485b 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -129,12 +129,6 @@ __attribute__((noreturn)) static void doexit(int status) } #endif -#if defined(SYZ_EXECUTOR) -// exit/_exit do not necessary work. -#define exit use_doexit_instead -#define _exit use_doexit_instead -#endif - #include "common.h" #if defined(SYZ_EXECUTOR) || defined(SYZ_HANDLE_SEGV) diff --git a/executor/common_windows.h b/executor/common_windows.h index 077bc874a..0edc473d7 100644 --- a/executor/common_windows.h +++ b/executor/common_windows.h @@ -5,7 +5,17 @@ #include -#define doexit exit +#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT)) || \ + defined(SYZ_USE_TMP_DIR) || defined(SYZ_HANDLE_SEGV) || defined(SYZ_TUN_ENABLE) || \ + defined(SYZ_SANDBOX_NAMESPACE) || defined(SYZ_SANDBOX_SETUID) || \ + defined(SYZ_SANDBOX_NONE) || defined(SYZ_FAULT_INJECTION) || defined(__NR_syz_kvm_setup_cpu) +__attribute__((noreturn)) static void doexit(int status) +{ + _exit(status); + for (;;) { + } +} +#endif #include "common.h" -- cgit mrf-deployment