From dd1609f876256c4305ac71591fed255880fa9ba7 Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Tue, 7 Nov 2017 17:11:20 +0100 Subject: executor: proceed even if /dev/net/tun is not available For some racy bugs syzkaller can generate a C reproducer with tun enabled, when it's not actuallly required to trigger the bug. Some kernel developers (that don't have CONFIG_TUN=y on their setups) complain about such C repros. When tun is not available, instead of exiting, print a message that tun initialization failed and proceed. --- pkg/csource/linux_common.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'pkg/csource/linux_common.go') diff --git a/pkg/csource/linux_common.go b/pkg/csource/linux_common.go index 2d84a9fbd..1e4d9f14b 100644 --- a/pkg/csource/linux_common.go +++ b/pkg/csource/linux_common.go @@ -431,8 +431,15 @@ static void initialize_tun(uint64_t pid) int id = pid; tunfd = open("/dev/net/tun", O_RDWR | O_NONBLOCK); - if (tunfd == -1) - fail("tun: can't open /dev/net/tun"); + if (tunfd == -1) { +#ifdef SYZ_EXECUTOR + fail("tun: can't open /dev/net/tun\n"); +#else + printf("tun: can't open /dev/net/tun: please enable CONFIG_TUN=y\n"); + printf("otherwise fuzzing or reproducing might not work as intended\n"); + return; +#endif + } char iface[IFNAMSIZ]; snprintf_check(iface, sizeof(iface), "syz%d", id); @@ -488,6 +495,9 @@ static void setup_tun(uint64_t pid, bool enable_tun) #if defined(SYZ_EXECUTOR) || (defined(SYZ_TUN_ENABLE) && (defined(__NR_syz_extract_tcp_res) || defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT))) static int read_tun(char* data, int size) { + if (tunfd < 0) + return -1; + int rv = read(tunfd, data, size); if (rv < 0) { if (errno == EAGAIN) -- cgit mrf-deployment