From a718501ca51a396a99c6db5dce884175f390aef9 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 4 Mar 2021 17:29:21 +0100 Subject: executor: disable rfkill during setup If rfkill is enabled by the fuzzer, wifi setup will fail. Disable rfkill to initial state during setup. --- executor/common_linux.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'executor') diff --git a/executor/common_linux.h b/executor/common_linux.h index 1d3500a57..3bd5edeca 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -961,6 +961,11 @@ static int nl80211_setup_ibss_interface(struct nlmsg* nlmsg, int sock, int nl802 #endif #if SYZ_EXECUTOR || SYZ_WIFI +#include +#include +#include +#include + static int hwsim80211_create_device(struct nlmsg* nlmsg, int sock, int hwsim_family, uint8 mac_addr[ETH_ALEN]) { struct genlmsghdr genlhdr; @@ -992,6 +997,19 @@ static void initialize_wifi_devices(void) if (!flag_wifi) return; #endif + int rfkill = open("/dev/rfkill", O_RDWR); + if (rfkill == -1) { + if (errno != ENOENT && errno != EACCES) + fail("open(/dev/rfkill) failed"); + } else { + struct rfkill_event event = {0}; + event.type = RFKILL_TYPE_ALL; + event.op = RFKILL_OP_CHANGE_ALL; + if (write(rfkill, &event, sizeof(event)) != (ssize_t)(sizeof(event))) + fail("write(/dev/rfkill) failed"); + close(rfkill); + } + uint8 mac_addr[6] = WIFI_MAC_BASE; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock < 0) { -- cgit mrf-deployment