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/executor.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'executor/executor.cc') diff --git a/executor/executor.cc b/executor/executor.cc index f1f6ba294..bbbb2da31 100644 --- a/executor/executor.cc +++ b/executor/executor.cc @@ -119,6 +119,7 @@ static bool flag_enable_net_dev; static bool flag_enable_net_reset; static bool flag_enable_cgroups; static bool flag_enable_binfmt_misc; +static bool flag_enable_close_fds; static bool flag_collect_cover; static bool flag_dedup_cover; @@ -454,6 +455,7 @@ void parse_env_flags(uint64 flags) flag_enable_net_reset = flags & (1 << 9); flag_enable_cgroups = flags & (1 << 10); flag_enable_binfmt_misc = flags & (1 << 11); + flag_enable_close_fds = flags & (1 << 12); } #if SYZ_EXECUTOR_USES_FORK_SERVER @@ -732,6 +734,10 @@ retry: } } +#if SYZ_HAVE_CLOSE_FDS + close_fds(); +#endif + if (flag_collide && !flag_inject_fault && !colliding && !collide) { debug("enabling collider\n"); collide = colliding = true; -- cgit mrf-deployment