diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2021-03-04 17:29:21 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2021-03-04 19:44:53 +0100 |
| commit | a718501ca51a396a99c6db5dce884175f390aef9 (patch) | |
| tree | 458a0bdbcb6e7d73dd6ae22d9250c6fd088185db /executor | |
| parent | 2da76713f113330c10d6a857c38927452bf57a61 (diff) | |
executor: disable rfkill during setup
If rfkill is enabled by the fuzzer, wifi setup will fail.
Disable rfkill to initial state during setup.
Diffstat (limited to 'executor')
| -rw-r--r-- | executor/common_linux.h | 18 |
1 files changed, 18 insertions, 0 deletions
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 <fcntl.h> +#include <linux/rfkill.h> +#include <sys/stat.h> +#include <sys/types.h> + 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) { |
