diff options
| author | Siddharth M <siddharth.muralee@gmail.com> | 2019-07-14 20:29:29 +0530 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2019-07-14 17:59:29 +0300 |
| commit | 2bbe2f05585bb06f9c417ee8437a8077c97b0de2 (patch) | |
| tree | 41b902498bad0bf6fbc479e877d4e59705f0682e /pkg/csource/generated.go | |
| parent | e6fb0f1316017fe45a21e19fc2ef5aea5b27d734 (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 'pkg/csource/generated.go')
| -rw-r--r-- | pkg/csource/generated.go | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go index 766ab6e28..3db1ee059 100644 --- a/pkg/csource/generated.go +++ b/pkg/csource/generated.go @@ -430,7 +430,7 @@ static uintptr_t syz_open_pts(void) #endif -#if GOOS_freebsd || GOOS_openbsd +#if GOOS_freebsd || GOOS_openbsd || GOOS_netbsd #if SYZ_EXECUTOR || SYZ_TUN_ENABLE @@ -506,7 +506,16 @@ 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 + 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 @@ -529,31 +538,26 @@ 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); #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 - 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); - 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); - 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); - 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); @@ -701,7 +705,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(); @@ -736,7 +740,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 |
