aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common_linux.h
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2017-11-07 17:11:20 +0100
committerAndrey Konovalov <andreyknvl@gmail.com>2017-11-08 17:43:40 +0100
commitdd1609f876256c4305ac71591fed255880fa9ba7 (patch)
tree3e20e872b450e35e516e221f52f005a9afdc2b57 /executor/common_linux.h
parent784eb9c23c498850bee1bed72914c17906071945 (diff)
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.
Diffstat (limited to 'executor/common_linux.h')
-rw-r--r--executor/common_linux.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/executor/common_linux.h b/executor/common_linux.h
index 48c23485b..f1d4239a4 100644
--- a/executor/common_linux.h
+++ b/executor/common_linux.h
@@ -295,8 +295,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);
@@ -358,6 +365,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)