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 /pkg/csource/generated.go | |
| 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 'pkg/csource/generated.go')
| -rw-r--r-- | pkg/csource/generated.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go index 62e9b0573..0b9e369dd 100644 --- a/pkg/csource/generated.go +++ b/pkg/csource/generated.go @@ -3187,6 +3187,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; @@ -3209,6 +3214,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) { |
