aboutsummaryrefslogtreecommitdiffstats
path: root/executor
diff options
context:
space:
mode:
authorSiddharth M <siddharth.muralee@gmail.com>2019-07-14 20:29:29 +0530
committerDmitry Vyukov <dvyukov@google.com>2019-07-14 17:59:29 +0300
commit2bbe2f05585bb06f9c417ee8437a8077c97b0de2 (patch)
tree41b902498bad0bf6fbc479e877d4e59705f0682e /executor
parente6fb0f1316017fe45a21e19fc2ef5aea5b27d734 (diff)
executor: add network packet injection for NetBSD
* Initial Commit * working build of network packet fuzzing * Add missed csource file * pkg/csource: fix build * executor/common_bsd.h: Add comment stating reason for ifconfig create
Diffstat (limited to 'executor')
-rw-r--r--executor/common_bsd.h28
-rw-r--r--executor/defs.h2
-rw-r--r--executor/syscalls.h3
3 files changed, 26 insertions, 7 deletions
diff --git a/executor/common_bsd.h b/executor/common_bsd.h
index d39d2aded..e483a41d1 100644
--- a/executor/common_bsd.h
+++ b/executor/common_bsd.h
@@ -37,7 +37,7 @@ static uintptr_t syz_open_pts(void)
#endif // GOOS_openbsd
-#if GOOS_freebsd || GOOS_openbsd
+#if GOOS_freebsd || GOOS_openbsd || GOOS_netbsd
#if SYZ_EXECUTOR || SYZ_TUN_ENABLE
@@ -123,7 +123,18 @@ static void initialize_tun(int tun_id)
char tun_device[sizeof(TUN_DEVICE)];
snprintf_check(tun_device, sizeof(tun_device), TUN_DEVICE, tun_id);
+
+ char tun_iface[sizeof(TUN_IFACE)];
+ snprintf_check(tun_iface, sizeof(tun_iface), TUN_IFACE, tun_id);
+
+#if GOOS_netbsd
+ // open(2) doesn't create an new tap/tun interface node
+ // so we use ifconfig to create the node. Might be casued due to regression
+ execute_command(0, "ifconfig %s destroy", tun_iface);
+ execute_command(0, "ifconfig %s create", tun_iface);
+#else
execute_command(0, "ifconfig %s destroy", tun_device);
+#endif
tunfd = open(tun_device, O_RDWR | O_NONBLOCK);
#if GOOS_freebsd
@@ -148,31 +159,36 @@ static void initialize_tun(int tun_id)
close(tunfd);
tunfd = kTunFd;
- char tun_iface[sizeof(TUN_IFACE)];
- snprintf_check(tun_iface, sizeof(tun_iface), TUN_IFACE, tun_id);
-
char local_mac[sizeof(LOCAL_MAC)];
snprintf_check(local_mac, sizeof(local_mac), LOCAL_MAC);
+
+ // Set the MAC address of the interface to LOCAL_MAC
#if GOOS_openbsd
execute_command(1, "ifconfig %s lladdr %s", tun_iface, local_mac);
+#elif GOOS_netbsd
+ execute_command(1, "ifconfig %s link %s", tun_iface, local_mac);
#else
execute_command(1, "ifconfig %s ether %s", tun_iface, local_mac);
#endif
+ // Setting up a static ip for the interface
char local_ipv4[sizeof(LOCAL_IPV4)];
snprintf_check(local_ipv4, sizeof(local_ipv4), LOCAL_IPV4, tun_id);
execute_command(1, "ifconfig %s inet %s netmask 255.255.255.0", tun_iface, local_ipv4);
+ // Creates an ARP table entry for the remote ip and MAC address
char remote_mac[sizeof(REMOTE_MAC)];
char remote_ipv4[sizeof(REMOTE_IPV4)];
snprintf_check(remote_mac, sizeof(remote_mac), REMOTE_MAC);
snprintf_check(remote_ipv4, sizeof(remote_ipv4), REMOTE_IPV4, tun_id);
execute_command(0, "arp -s %s %s", remote_ipv4, remote_mac);
+ // Set up a static ipv6 address for the interface
char local_ipv6[sizeof(LOCAL_IPV6)];
snprintf_check(local_ipv6, sizeof(local_ipv6), LOCAL_IPV6, tun_id);
execute_command(1, "ifconfig %s inet6 %s", tun_iface, local_ipv6);
+ // Registers an NDP entry for the remote MAC with the remote ipv6 address
char remote_ipv6[sizeof(REMOTE_IPV6)];
snprintf_check(remote_ipv6, sizeof(remote_ipv6), REMOTE_IPV6, tun_id);
execute_command(0, "ndp -s %s%%%s %s", remote_ipv6, tun_iface, remote_mac);
@@ -332,7 +348,7 @@ static void loop();
static int do_sandbox_none(void)
{
sandbox_common();
-#if (GOOS_freebsd || GOOS_openbsd) && (SYZ_EXECUTOR || SYZ_TUN_ENABLE)
+#if (GOOS_freebsd || GOOS_openbsd || GOOS_netbsd) && (SYZ_EXECUTOR || SYZ_TUN_ENABLE)
initialize_tun(procid);
#endif
loop();
@@ -367,7 +383,7 @@ static int do_sandbox_setuid(void)
return wait_for_loop(pid);
sandbox_common();
-#if (GOOS_freebsd || GOOS_openbsd) && (SYZ_EXECUTOR || SYZ_TUN_ENABLE)
+#if (GOOS_freebsd || GOOS_openbsd || GOOS_netbsd) && (SYZ_EXECUTOR || SYZ_TUN_ENABLE)
initialize_tun(procid);
#endif
diff --git a/executor/defs.h b/executor/defs.h
index fe7d12e32..aa5a64c95 100644
--- a/executor/defs.h
+++ b/executor/defs.h
@@ -125,7 +125,7 @@
#if GOARCH_amd64
#define GOARCH "amd64"
-#define SYZ_REVISION "71ea2d6047354a28057976d7ea40a5f24673a27c"
+#define SYZ_REVISION "65d5b75dae9655ed21ef93383407c6108cf4de62"
#define SYZ_EXECUTOR_USES_FORK_SERVER 1
#define SYZ_EXECUTOR_USES_SHMEM 1
#define SYZ_PAGE_SIZE 4096
diff --git a/executor/syscalls.h b/executor/syscalls.h
index 3665c8897..fb6b5f64f 100644
--- a/executor/syscalls.h
+++ b/executor/syscalls.h
@@ -15804,7 +15804,10 @@ const call_t syscalls[] = {
{"symlink", 57},
{"symlinkat", 470},
{"sync", 36},
+ {"syz_emit_ethernet", 0, (syscall_t)syz_emit_ethernet},
{"syz_execute_func", 0, (syscall_t)syz_execute_func},
+ {"syz_extract_tcp_res", 0, (syscall_t)syz_extract_tcp_res},
+ {"syz_extract_tcp_res$synack", 0, (syscall_t)syz_extract_tcp_res},
{"truncate", 200},
{"unlink", 10},
{"unlinkat", 471},