From 5c51045d28eb1ad9465a51487d436133ce7b98d2 Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Fri, 5 Apr 2019 18:44:53 +0200 Subject: all: add optional close_fds feature to reproducers Instead of always closing open fds (number 3 to 30) after each program, add an options called EnableCloseFds. It can be passed to syz-execprog, syz-prog2c and syz-stress via the -enable and -disable flags. Set the default value to true. Also minimize C repros over it, except for when repeat is enabled. --- executor/common_linux.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'executor/common_linux.h') diff --git a/executor/common_linux.h b/executor/common_linux.h index b84955577..0fd7a1582 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -2612,12 +2612,20 @@ static void setup_test() flush_tun(); #endif } +#endif -#define SYZ_HAVE_RESET_TEST 1 -static void reset_test() +#if SYZ_EXECUTOR || SYZ_ENABLE_CLOSE_FDS +#define SYZ_HAVE_CLOSE_FDS 1 +static void close_fds() { +#if SYZ_EXECUTOR + if (!flag_enable_close_fds) + return; +#endif // Keeping a 9p transport pipe open will hang the proccess dead, // so close all opened file descriptors. + // Also close all USB emulation descriptors to trigger exit from USB + // event loop to collect coverage. int fd; for (fd = 3; fd < 30; fd++) close(fd); -- cgit mrf-deployment