diff options
| author | Andy Nguyen <theflow@google.com> | 2020-08-23 11:51:54 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-08-23 12:31:52 +0200 |
| commit | 5bde7c3b04ebdee3e83abb0f53ba985ae937e2ea (patch) | |
| tree | e2ccbc097e082458e43fb59423286001665f6822 /executor/common_linux.h | |
| parent | a6d5f3ad1385fe724cdb2c9ee3b05c7d4ce48ef6 (diff) | |
executor/common_linux.h: unblock rfkill and retry HCIDEVUP on ERFKILL
Diffstat (limited to 'executor/common_linux.h')
| -rw-r--r-- | executor/common_linux.h | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/executor/common_linux.h b/executor/common_linux.h index 68be3eeff..410e97bdc 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -1981,6 +1981,7 @@ static long syz_init_net_socket(volatile long domain, volatile long type, volati #if SYZ_EXECUTOR || SYZ_VHCI_INJECTION #include <errno.h> #include <fcntl.h> +#include <linux/rfkill.h> #include <pthread.h> #include <sys/epoll.h> #include <sys/ioctl.h> @@ -2089,6 +2090,22 @@ struct vhci_vendor_pkt { static int vhci_fd = -1; +void rfkill_unblock_all() +{ + int fd = open("/dev/rfkill", O_WRONLY); + if (fd < 0) + fail("open /dev/rfkill failed"); + struct rfkill_event event = {0}; + event.idx = 0; + event.type = RFKILL_TYPE_ALL; + event.op = RFKILL_OP_CHANGE_ALL; + event.soft = 0; + event.hard = 0; + if (write(fd, &event, sizeof(event)) < 0) + fail("write rfkill event failed\n"); + close(fd); +} + static void hci_send_event_packet(int fd, uint8 evt, void* data, size_t data_len) { struct iovec iv[3]; @@ -2232,8 +2249,16 @@ static void initialize_vhci() fail("pthread_create failed"); // Bring hci device up - if (ioctl(hci_sock, HCIDEVUP, vendor_pkt.id) && errno != EALREADY) - fail("ioctl(HCIDEVUP) failed"); + int ret = ioctl(hci_sock, HCIDEVUP, vendor_pkt.id); + if (ret) { + if (errno == ERFKILL) { + rfkill_unblock_all(); + ret = ioctl(hci_sock, HCIDEVUP, vendor_pkt.id); + } + + if (ret && errno != EALREADY) + fail("ioctl(HCIDEVUP) failed"); + } // Activate page scanning mode which is required to fake a connection. struct hci_dev_req dr = {0}; |
