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.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'executor/common.h') diff --git a/executor/common.h b/executor/common.h index 5f33d3bf5..10e5b960b 100644 --- a/executor/common.h +++ b/executor/common.h @@ -483,6 +483,9 @@ again: } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); +#if SYZ_HAVE_CLOSE_FDS + close_fds(); +#endif #if SYZ_COLLIDE if (!collide) { collide = 1; @@ -571,8 +574,8 @@ static void loop(void) close(kOutPipeFd); #endif execute_one(); -#if SYZ_HAVE_RESET_TEST - reset_test(); +#if SYZ_HAVE_CLOSE_FDS && !SYZ_THREADED + close_fds(); #endif doexit(0); #endif @@ -659,6 +662,9 @@ void loop(void) #endif { /*SYSCALLS*/ +#if SYZ_HAVE_CLOSE_FDS && !SYZ_THREADED && !SYZ_REPEAT + close_fds(); +#endif } #endif @@ -690,6 +696,10 @@ int main(void) use_temporary_dir(); #endif /*SANDBOX_FUNC*/ +#if SYZ_HAVE_CLOSE_FDS && !SYZ_THREADED && !SYZ_REPEAT && !SYZ_SANDBOX_NONE && \ + !SYZ_SANDBOX_SETUID && !SYZ_SANDBOX_NAMESPACE && !SYZ_SANDBOX_ANDROID_UNTRUSTED_APP + close_fds(); +#endif #if SYZ_PROCS } } -- cgit mrf-deployment