// https://syzkaller.appspot.com/bug?id=47ca2ff42f9c5d5d353149ecc97f29de7828bbfd // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef SYS_mmap #define SYS_mmap 197 #endif static unsigned long long procid; static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { pthread_mutex_t mu; pthread_cond_t cv; int state; } event_t; static void event_init(event_t* ev) { if (pthread_mutex_init(&ev->mu, 0)) exit(1); if (pthread_cond_init(&ev->cv, 0)) exit(1); ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { pthread_mutex_lock(&ev->mu); if (ev->state) exit(1); ev->state = 1; pthread_mutex_unlock(&ev->mu); pthread_cond_broadcast(&ev->cv); } static void event_wait(event_t* ev) { pthread_mutex_lock(&ev->mu); while (!ev->state) pthread_cond_wait(&ev->cv, &ev->mu); pthread_mutex_unlock(&ev->mu); } static int event_isset(event_t* ev) { pthread_mutex_lock(&ev->mu); int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; pthread_mutex_lock(&ev->mu); for (;;) { if (ev->state) break; uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; pthread_cond_timedwait(&ev->cv, &ev->mu, &ts); now = current_time_ms(); if (now - start > timeout) break; } int res = ev->state; pthread_mutex_unlock(&ev->mu); return res; } #define BITMASK(bf_off, bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type, htobe, addr, val, bf_off, bf_len) \ *(type*)(addr) = \ htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | \ (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct usb_endpoint_descriptor { uint8_t bLength; uint8_t bDescriptorType; uint8_t bEndpointAddress; uint8_t bmAttributes; uint16_t wMaxPacketSize; uint8_t bInterval; uint8_t bRefresh; uint8_t bSynchAddress; } __attribute__((packed)); struct usb_device_descriptor { uint8_t bLength; uint8_t bDescriptorType; uint16_t bcdUSB; uint8_t bDeviceClass; uint8_t bDeviceSubClass; uint8_t bDeviceProtocol; uint8_t bMaxPacketSize0; uint16_t idVendor; uint16_t idProduct; uint16_t bcdDevice; uint8_t iManufacturer; uint8_t iProduct; uint8_t iSerialNumber; uint8_t bNumConfigurations; } __attribute__((packed)); struct usb_config_descriptor { uint8_t bLength; uint8_t bDescriptorType; uint16_t wTotalLength; uint8_t bNumInterfaces; uint8_t bConfigurationValue; uint8_t iConfiguration; uint8_t bmAttributes; uint8_t bMaxPower; } __attribute__((packed)); struct usb_interface_descriptor { uint8_t bLength; uint8_t bDescriptorType; uint8_t bInterfaceNumber; uint8_t bAlternateSetting; uint8_t bNumEndpoints; uint8_t bInterfaceClass; uint8_t bInterfaceSubClass; uint8_t bInterfaceProtocol; uint8_t iInterface; } __attribute__((packed)); struct usb_ctrlrequest { uint8_t bRequestType; uint8_t bRequest; uint16_t wValue; uint16_t wIndex; uint16_t wLength; } __attribute__((packed)); struct usb_qualifier_descriptor { uint8_t bLength; uint8_t bDescriptorType; uint16_t bcdUSB; uint8_t bDeviceClass; uint8_t bDeviceSubClass; uint8_t bDeviceProtocol; uint8_t bMaxPacketSize0; uint8_t bNumConfigurations; uint8_t bRESERVED; } __attribute__((packed)); #define USB_TYPE_MASK (0x03 << 5) #define USB_TYPE_STANDARD (0x00 << 5) #define USB_TYPE_CLASS (0x01 << 5) #define USB_TYPE_VENDOR (0x02 << 5) #define USB_TYPE_RESERVED (0x03 << 5) #define USB_DT_DEVICE 0x01 #define USB_DT_CONFIG 0x02 #define USB_DT_STRING 0x03 #define USB_DT_INTERFACE 0x04 #define USB_DT_ENDPOINT 0x05 #define USB_DT_DEVICE_QUALIFIER 0x06 #define USB_DT_OTHER_SPEED_CONFIG 0x07 #define USB_DT_INTERFACE_POWER 0x08 #define USB_DT_OTG 0x09 #define USB_DT_DEBUG 0x0a #define USB_DT_INTERFACE_ASSOCIATION 0x0b #define USB_DT_SECURITY 0x0c #define USB_DT_KEY 0x0d #define USB_DT_ENCRYPTION_TYPE 0x0e #define USB_DT_BOS 0x0f #define USB_DT_DEVICE_CAPABILITY 0x10 #define USB_DT_WIRELESS_ENDPOINT_COMP 0x11 #define USB_DT_WIRE_ADAPTER 0x21 #define USB_DT_RPIPE 0x22 #define USB_DT_CS_RADIO_CONTROL 0x23 #define USB_DT_PIPE_USAGE 0x24 #define USB_DT_SS_ENDPOINT_COMP 0x30 #define USB_DT_SSP_ISOC_ENDPOINT_COMP 0x31 #define USB_REQ_GET_STATUS 0x00 #define USB_REQ_CLEAR_FEATURE 0x01 #define USB_REQ_SET_FEATURE 0x03 #define USB_REQ_SET_ADDRESS 0x05 #define USB_REQ_GET_DESCRIPTOR 0x06 #define USB_REQ_SET_DESCRIPTOR 0x07 #define USB_REQ_GET_CONFIGURATION 0x08 #define USB_REQ_SET_CONFIGURATION 0x09 #define USB_REQ_GET_INTERFACE 0x0A #define USB_REQ_SET_INTERFACE 0x0B #define USB_REQ_SYNCH_FRAME 0x0C #define USB_REQ_SET_SEL 0x30 #define USB_REQ_SET_ISOCH_DELAY 0x31 #define USB_REQ_SET_ENCRYPTION 0x0D #define USB_REQ_GET_ENCRYPTION 0x0E #define USB_REQ_RPIPE_ABORT 0x0E #define USB_REQ_SET_HANDSHAKE 0x0F #define USB_REQ_RPIPE_RESET 0x0F #define USB_REQ_GET_HANDSHAKE 0x10 #define USB_REQ_SET_CONNECTION 0x11 #define USB_REQ_SET_SECURITY_DATA 0x12 #define USB_REQ_GET_SECURITY_DATA 0x13 #define USB_REQ_SET_WUSB_DATA 0x14 #define USB_REQ_LOOPBACK_DATA_WRITE 0x15 #define USB_REQ_LOOPBACK_DATA_READ 0x16 #define USB_REQ_SET_INTERFACE_DS 0x17 #define USB_REQ_GET_PARTNER_PDO 20 #define USB_REQ_GET_BATTERY_STATUS 21 #define USB_REQ_SET_PDO 22 #define USB_REQ_GET_VDM 23 #define USB_REQ_SEND_VDM 24 #define USB_MAX_IFACE_NUM 4 #define USB_MAX_EP_NUM 32 #define USB_MAX_FDS 6 struct usb_endpoint_index { struct usb_endpoint_descriptor desc; int handle; }; struct usb_iface_index { struct usb_interface_descriptor* iface; uint8_t bInterfaceNumber; uint8_t bAlternateSetting; uint8_t bInterfaceClass; struct usb_endpoint_index eps[USB_MAX_EP_NUM]; int eps_num; }; struct usb_device_index { struct usb_device_descriptor* dev; struct usb_config_descriptor* config; uint8_t bDeviceClass; uint8_t bMaxPower; int config_length; struct usb_iface_index ifaces[USB_MAX_IFACE_NUM]; int ifaces_num; int iface_cur; }; struct usb_info { int fd; struct usb_device_index index; }; static struct usb_info usb_devices[USB_MAX_FDS]; static int usb_devices_num; static bool parse_usb_descriptor(const char* buffer, size_t length, struct usb_device_index* index) { if (length < sizeof(*index->dev) + sizeof(*index->config)) return false; memset(index, 0, sizeof(*index)); index->dev = (struct usb_device_descriptor*)buffer; index->config = (struct usb_config_descriptor*)(buffer + sizeof(*index->dev)); index->bDeviceClass = index->dev->bDeviceClass; index->bMaxPower = index->config->bMaxPower; index->config_length = length - sizeof(*index->dev); index->iface_cur = -1; size_t offset = 0; while (true) { if (offset + 1 >= length) break; uint8_t desc_length = buffer[offset]; uint8_t desc_type = buffer[offset + 1]; if (desc_length <= 2) break; if (offset + desc_length > length) break; if (desc_type == USB_DT_INTERFACE && index->ifaces_num < USB_MAX_IFACE_NUM) { struct usb_interface_descriptor* iface = (struct usb_interface_descriptor*)(buffer + offset); index->ifaces[index->ifaces_num].iface = iface; index->ifaces[index->ifaces_num].bInterfaceNumber = iface->bInterfaceNumber; index->ifaces[index->ifaces_num].bAlternateSetting = iface->bAlternateSetting; index->ifaces[index->ifaces_num].bInterfaceClass = iface->bInterfaceClass; index->ifaces_num++; } if (desc_type == USB_DT_ENDPOINT && index->ifaces_num > 0) { struct usb_iface_index* iface = &index->ifaces[index->ifaces_num - 1]; if (iface->eps_num < USB_MAX_EP_NUM) { memcpy(&iface->eps[iface->eps_num].desc, buffer + offset, sizeof(iface->eps[iface->eps_num].desc)); iface->eps_num++; } } offset += desc_length; } return true; } static struct usb_device_index* add_usb_index(int fd, const char* dev, size_t dev_len) { int i = __atomic_fetch_add(&usb_devices_num, 1, __ATOMIC_RELAXED); if (i >= USB_MAX_FDS) return NULL; if (!parse_usb_descriptor(dev, dev_len, &usb_devices[i].index)) return NULL; __atomic_store_n(&usb_devices[i].fd, fd, __ATOMIC_RELEASE); return &usb_devices[i].index; } static struct usb_device_index* lookup_usb_index(int fd) { for (int i = 0; i < USB_MAX_FDS; i++) { if (__atomic_load_n(&usb_devices[i].fd, __ATOMIC_ACQUIRE) == fd) return &usb_devices[i].index; } return NULL; } struct vusb_connect_string_descriptor { uint32_t len; char* str; } __attribute__((packed)); struct vusb_connect_descriptors { uint32_t qual_len; char* qual; uint32_t bos_len; char* bos; uint32_t strs_len; struct vusb_connect_string_descriptor strs[0]; } __attribute__((packed)); static const char default_string[] = {8, USB_DT_STRING, 's', 0, 'y', 0, 'z', 0}; static const char default_lang_id[] = {4, USB_DT_STRING, 0x09, 0x04}; static bool lookup_connect_response_in(int fd, const struct vusb_connect_descriptors* descs, const struct usb_ctrlrequest* ctrl, char** response_data, uint32_t* response_length) { struct usb_device_index* index = lookup_usb_index(fd); uint8_t str_idx; if (!index) return false; switch (ctrl->bRequestType & USB_TYPE_MASK) { case USB_TYPE_STANDARD: switch (ctrl->bRequest) { case USB_REQ_GET_DESCRIPTOR: switch (ctrl->wValue >> 8) { case USB_DT_DEVICE: *response_data = (char*)index->dev; *response_length = sizeof(*index->dev); return true; case USB_DT_CONFIG: *response_data = (char*)index->config; *response_length = index->config_length; return true; case USB_DT_STRING: str_idx = (uint8_t)ctrl->wValue; if (descs && str_idx < descs->strs_len) { *response_data = descs->strs[str_idx].str; *response_length = descs->strs[str_idx].len; return true; } if (str_idx == 0) { *response_data = (char*)&default_lang_id[0]; *response_length = default_lang_id[0]; return true; } *response_data = (char*)&default_string[0]; *response_length = default_string[0]; return true; case USB_DT_BOS: *response_data = descs->bos; *response_length = descs->bos_len; return true; case USB_DT_DEVICE_QUALIFIER: if (!descs->qual) { struct usb_qualifier_descriptor* qual = (struct usb_qualifier_descriptor*)response_data; qual->bLength = sizeof(*qual); qual->bDescriptorType = USB_DT_DEVICE_QUALIFIER; qual->bcdUSB = index->dev->bcdUSB; qual->bDeviceClass = index->dev->bDeviceClass; qual->bDeviceSubClass = index->dev->bDeviceSubClass; qual->bDeviceProtocol = index->dev->bDeviceProtocol; qual->bMaxPacketSize0 = index->dev->bMaxPacketSize0; qual->bNumConfigurations = index->dev->bNumConfigurations; qual->bRESERVED = 0; *response_length = sizeof(*qual); return true; } *response_data = descs->qual; *response_length = descs->qual_len; return true; default: break; } break; default: break; } break; default: break; } return false; } typedef bool (*lookup_connect_out_response_t)( int fd, const struct vusb_connect_descriptors* descs, const struct usb_ctrlrequest* ctrl, bool* done); static bool lookup_connect_response_out_generic( int fd, const struct vusb_connect_descriptors* descs, const struct usb_ctrlrequest* ctrl, bool* done) { switch (ctrl->bRequestType & USB_TYPE_MASK) { case USB_TYPE_STANDARD: switch (ctrl->bRequest) { case USB_REQ_SET_CONFIGURATION: *done = true; return true; default: break; } break; } return false; } static int vhci_open(void) { char path[1024]; snprintf(path, sizeof(path), "/dev/vhci%llu", procid); return open(path, O_RDWR); } static int vhci_setport(int fd, u_int port) { struct vhci_ioc_set_port args; args.port = port; return ioctl(fd, VHCI_IOC_SET_PORT, &args); } static int vhci_usb_attach(int fd) { return ioctl(fd, VHCI_IOC_USB_ATTACH, NULL); } static int vhci_usb_recv(int fd, void* buf, size_t size) { uint8_t* ptr = (uint8_t*)buf; while (1) { ssize_t done = read(fd, ptr, size); if (done < 0) return -1; if ((size_t)done == size) return 0; size -= done; ptr += done; } } static int vhci_usb_send(int fd, void* buf, size_t size) { uint8_t* ptr = (uint8_t*)buf; while (1) { ssize_t done = write(fd, ptr, size); if (done <= 0) return -1; if ((size_t)done == size) return 0; size -= done; ptr += done; } } static volatile long syz_usb_connect_impl(int fd, uint64_t speed, uint64_t dev_len, const char* dev, const struct vusb_connect_descriptors* descs, lookup_connect_out_response_t lookup_connect_response_out) { struct usb_device_index* index = add_usb_index(fd, dev, dev_len); if (!index) { return -1; } if (vhci_setport(fd, 1)) exit(1); if (vhci_usb_attach(fd)) { return -1; } bool done = false; while (!done) { vhci_request_t req; if (vhci_usb_recv(fd, &req, sizeof(req))) { return -1; } if (req.type != VHCI_REQ_CTRL) { return -1; } char* response_data = NULL; uint32_t response_length = 0; char data[4096]; if (req.u.ctrl.bmRequestType & UE_DIR_IN) { if (!lookup_connect_response_in( fd, descs, (const struct usb_ctrlrequest*)&req.u.ctrl, &response_data, &response_length)) { return -1; } } else { if (!lookup_connect_response_out( fd, descs, (const struct usb_ctrlrequest*)&req.u.ctrl, &done)) { return -1; } response_data = NULL; response_length = UGETW(req.u.ctrl.wLength); } if ((req.u.ctrl.bmRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD && req.u.ctrl.bRequest == USB_REQ_SET_CONFIGURATION) { } if (response_length > sizeof(data)) response_length = 0; if ((uint32_t)UGETW(req.u.ctrl.wLength) < response_length) response_length = UGETW(req.u.ctrl.wLength); if (response_data) memcpy(data, response_data, response_length); else memset(data, 0, response_length); int rv = 0; if (req.u.ctrl.bmRequestType & UE_DIR_IN) { if (response_length > 0) { vhci_response_t res; res.size = response_length; rv = vhci_usb_send(fd, &res, sizeof(res)); if (rv == 0) rv = vhci_usb_send(fd, data, response_length); } } else { rv = vhci_usb_recv(fd, data, response_length); } if (rv < 0) { return -1; } } sleep_ms(200); return fd; } static volatile long syz_usb_connect(volatile long a0, volatile long a1, volatile long a2, volatile long a3) { uint64_t speed = a0; uint64_t dev_len = a1; const char* dev = (const char*)a2; const struct vusb_connect_descriptors* descs = (const struct vusb_connect_descriptors*)a3; if (!dev) { return -1; } int fd = vhci_open(); if (fd < 0) exit(1); long res = syz_usb_connect_impl(fd, speed, dev_len, dev, descs, &lookup_connect_response_out_generic); close(fd); return res; } static void sandbox_common() { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); } static void loop(); static int do_sandbox_none(void) { sandbox_common(); loop(); return 0; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 3; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (call == 1) break; event_timedwait(&th->done, 50 + (call == 0 ? 3000 : 0) + (call == 1 ? 3000 : 0) + (call == 2 ? 3000 : 0)); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } } } void execute_call(int call) { switch (call) { case 0: *(uint8_t*)0x20000000 = 0x12; *(uint8_t*)0x20000001 = 1; *(uint16_t*)0x20000002 = 0x110; *(uint8_t*)0x20000004 = 2; *(uint8_t*)0x20000005 = 0; *(uint8_t*)0x20000006 = 0; *(uint8_t*)0x20000007 = 0x20; *(uint16_t*)0x20000008 = 0x525; *(uint16_t*)0x2000000a = 0xa4a1; *(uint16_t*)0x2000000c = 0x40; *(uint8_t*)0x2000000e = 1; *(uint8_t*)0x2000000f = 2; *(uint8_t*)0x20000010 = 3; *(uint8_t*)0x20000011 = 1; *(uint8_t*)0x20000012 = 9; *(uint8_t*)0x20000013 = 2; *(uint16_t*)0x20000014 = 0x48; *(uint8_t*)0x20000016 = 1; *(uint8_t*)0x20000017 = 1; *(uint8_t*)0x20000018 = 6; *(uint8_t*)0x20000019 = 0x10; *(uint8_t*)0x2000001a = 7; *(uint8_t*)0x2000001b = 9; *(uint8_t*)0x2000001c = 4; *(uint8_t*)0x2000001d = 0; *(uint8_t*)0x2000001e = 8; *(uint8_t*)0x2000001f = 2; *(uint8_t*)0x20000020 = 2; *(uint8_t*)0x20000021 = 6; *(uint8_t*)0x20000022 = 0; *(uint8_t*)0x20000023 = 0x1f; *(uint8_t*)0x20000024 = 5; *(uint8_t*)0x20000025 = 0x24; *(uint8_t*)0x20000026 = 6; *(uint8_t*)0x20000027 = 0; *(uint8_t*)0x20000028 = 0; *(uint8_t*)0x20000029 = 5; *(uint8_t*)0x2000002a = 0x24; *(uint8_t*)0x2000002b = 0; *(uint16_t*)0x2000002c = 9; *(uint8_t*)0x2000002e = 0xd; *(uint8_t*)0x2000002f = 0x24; *(uint8_t*)0x20000030 = 0xf; *(uint8_t*)0x20000031 = 1; *(uint32_t*)0x20000032 = 0; *(uint16_t*)0x20000036 = 4; *(uint16_t*)0x20000038 = 5; *(uint8_t*)0x2000003a = 0x80; *(uint8_t*)0x2000003b = 7; *(uint8_t*)0x2000003c = 0x24; *(uint8_t*)0x2000003d = 0xa; *(uint8_t*)0x2000003e = 6; *(uint8_t*)0x2000003f = 0; *(uint8_t*)0x20000040 = 8; *(uint8_t*)0x20000041 = 7; *(uint8_t*)0x20000042 = 6; *(uint8_t*)0x20000043 = 0x24; *(uint8_t*)0x20000044 = 0x1a; *(uint16_t*)0x20000045 = 0x464; *(uint8_t*)0x20000047 = 0x14; *(uint8_t*)0x20000048 = 9; *(uint8_t*)0x20000049 = 5; *(uint8_t*)0x2000004a = 0x82; *(uint8_t*)0x2000004b = 2; *(uint16_t*)0x2000004c = 0x20; *(uint8_t*)0x2000004e = 0xcf; *(uint8_t*)0x2000004f = 9; *(uint8_t*)0x20000050 = 0xb7; *(uint8_t*)0x20000051 = 9; *(uint8_t*)0x20000052 = 5; *(uint8_t*)0x20000053 = 3; *(uint8_t*)0x20000054 = 2; *(uint16_t*)0x20000055 = 0x400; *(uint8_t*)0x20000057 = 1; *(uint8_t*)0x20000058 = 0x20; *(uint8_t*)0x20000059 = 0x20; *(uint32_t*)0x20000180 = 0; *(uint64_t*)0x20000184 = 0; *(uint32_t*)0x2000018c = 0x1a; *(uint64_t*)0x20000190 = 0x200000c0; *(uint8_t*)0x200000c0 = 5; *(uint8_t*)0x200000c1 = 0xf; *(uint16_t*)0x200000c2 = 0x1a; *(uint8_t*)0x200000c4 = 2; *(uint8_t*)0x200000c5 = 0xb; *(uint8_t*)0x200000c6 = 0x10; *(uint8_t*)0x200000c7 = 1; *(uint8_t*)0x200000c8 = 2; *(uint16_t*)0x200000c9 = 0; *(uint8_t*)0x200000cb = 3; *(uint8_t*)0x200000cc = 6; *(uint16_t*)0x200000cd = 0x401; *(uint8_t*)0x200000cf = -1; *(uint8_t*)0x200000d0 = 0xa; *(uint8_t*)0x200000d1 = 0x10; *(uint8_t*)0x200000d2 = 3; *(uint8_t*)0x200000d3 = 0; *(uint16_t*)0x200000d4 = 0xa; *(uint8_t*)0x200000d6 = 0x87; *(uint8_t*)0x200000d7 = -1; *(uint16_t*)0x200000d8 = 0x8001; *(uint32_t*)0x20000198 = 2; *(uint32_t*)0x2000019c = 4; *(uint64_t*)0x200001a0 = 0x20000100; *(uint8_t*)0x20000100 = 4; *(uint8_t*)0x20000101 = 3; *(uint16_t*)0x20000102 = 0x437; *(uint32_t*)0x200001a8 = 4; *(uint64_t*)0x200001ac = 0x20000140; *(uint8_t*)0x20000140 = 4; *(uint8_t*)0x20000141 = 3; *(uint16_t*)0x20000142 = 0x860; syz_usb_connect(0, 0x5a, 0x20000000, 0x20000180); break; case 1: *(uint8_t*)0x20001a40 = 0x12; *(uint8_t*)0x20001a41 = 1; *(uint16_t*)0x20001a42 = 0x201; *(uint8_t*)0x20001a44 = 0; *(uint8_t*)0x20001a45 = 0; *(uint8_t*)0x20001a46 = 0; *(uint8_t*)0x20001a47 = -1; *(uint16_t*)0x20001a48 = 0x525; *(uint16_t*)0x20001a4a = 0xa4a8; *(uint16_t*)0x20001a4c = 0x40; *(uint8_t*)0x20001a4e = 1; *(uint8_t*)0x20001a4f = 2; *(uint8_t*)0x20001a50 = 3; *(uint8_t*)0x20001a51 = 1; *(uint8_t*)0x20001a52 = 9; *(uint8_t*)0x20001a53 = 2; *(uint16_t*)0x20001a54 = 0x24; *(uint8_t*)0x20001a56 = 1; *(uint8_t*)0x20001a57 = 1; *(uint8_t*)0x20001a58 = 0x7f; *(uint8_t*)0x20001a59 = 0x40; *(uint8_t*)0x20001a5a = 6; *(uint8_t*)0x20001a5b = 9; *(uint8_t*)0x20001a5c = 4; *(uint8_t*)0x20001a5d = 0; *(uint8_t*)0x20001a5e = 0x1f; *(uint8_t*)0x20001a5f = 1; *(uint8_t*)0x20001a60 = 7; *(uint8_t*)0x20001a61 = 1; *(uint8_t*)0x20001a62 = 3; *(uint8_t*)0x20001a63 = 4; *(uint8_t*)0x20001a64 = 9; *(uint8_t*)0x20001a65 = 5; *(uint8_t*)0x20001a66 = 1; *(uint8_t*)0x20001a67 = 2; *(uint16_t*)0x20001a68 = 8; *(uint8_t*)0x20001a6a = 0; *(uint8_t*)0x20001a6b = 3; *(uint8_t*)0x20001a6c = 3; *(uint8_t*)0x20001a6d = 9; *(uint8_t*)0x20001a6e = 5; *(uint8_t*)0x20001a6f = 0x82; *(uint8_t*)0x20001a70 = 2; *(uint16_t*)0x20001a71 = 0x200; *(uint8_t*)0x20001a73 = 0x1f; *(uint8_t*)0x20001a74 = 6; *(uint8_t*)0x20001a75 = 0; *(uint32_t*)0x20001bc0 = 0xa; *(uint64_t*)0x20001bc4 = 0x20001a80; *(uint8_t*)0x20001a80 = 0xa; *(uint8_t*)0x20001a81 = 6; *(uint16_t*)0x20001a82 = 0x201; *(uint8_t*)0x20001a84 = 6; *(uint8_t*)0x20001a85 = 8; *(uint8_t*)0x20001a86 = 0x3f; *(uint8_t*)0x20001a87 = -1; *(uint8_t*)0x20001a88 = 0x88; *(uint8_t*)0x20001a89 = 0; *(uint32_t*)0x20001bcc = 0; *(uint64_t*)0x20001bd0 = 0; *(uint32_t*)0x20001bd8 = 1; *(uint32_t*)0x20001bdc = 2; *(uint64_t*)0x20001be0 = 0x20001b00; *(uint8_t*)0x20001b00 = 2; *(uint8_t*)0x20001b01 = 3; syz_usb_connect(5, 0x36, 0x20001a40, 0x20001bc0); break; case 2: *(uint8_t*)0x200001c0 = 0x12; *(uint8_t*)0x200001c1 = 1; *(uint16_t*)0x200001c2 = 0x201; *(uint8_t*)0x200001c4 = 0; *(uint8_t*)0x200001c5 = 0; *(uint8_t*)0x200001c6 = 0; *(uint8_t*)0x200001c7 = 0x20; *(uint16_t*)0x200001c8 = 0; *(uint16_t*)0x200001ca = 0; *(uint16_t*)0x200001cc = 0x40; *(uint8_t*)0x200001ce = 1; *(uint8_t*)0x200001cf = 2; *(uint8_t*)0x200001d0 = 3; *(uint8_t*)0x200001d1 = 1; *(uint8_t*)0x200001d2 = 9; *(uint8_t*)0x200001d3 = 2; *(uint16_t*)0x200001d4 = 0x24; *(uint8_t*)0x200001d6 = 1; *(uint8_t*)0x200001d7 = 1; *(uint8_t*)0x200001d8 = 0x3f; *(uint8_t*)0x200001d9 = 0xb0; *(uint8_t*)0x200001da = 3; *(uint8_t*)0x200001db = 9; *(uint8_t*)0x200001dc = 4; *(uint8_t*)0x200001dd = 0; *(uint8_t*)0x200001de = 3; *(uint8_t*)0x200001df = 2; *(uint8_t*)0x200001e0 = 3; *(uint8_t*)0x200001e1 = 1; *(uint8_t*)0x200001e2 = 0; *(uint8_t*)0x200001e3 = 2; *(uint8_t*)0x200001e4 = 9; *(uint8_t*)0x200001e5 = 0x21; *(uint16_t*)0x200001e6 = 0x6cb; *(uint8_t*)0x200001e8 = 2; *(uint8_t*)0x200001e9 = 1; *(uint8_t*)0x200001ea = 0x22; *(uint16_t*)0x200001eb = 0xf73; *(uint8_t*)0x200001ed = 9; *(uint8_t*)0x200001ee = 5; *(uint8_t*)0x200001ef = 0x81; *(uint8_t*)0x200001f0 = 3; *(uint16_t*)0x200001f1 = 0x3ff; *(uint8_t*)0x200001f3 = 8; *(uint8_t*)0x200001f4 = 0x1f; *(uint8_t*)0x200001f5 = 0; *(uint32_t*)0x200006c0 = 0; *(uint64_t*)0x200006c4 = 0; *(uint32_t*)0x200006cc = 0x2f; *(uint64_t*)0x200006d0 = 0x20000240; *(uint8_t*)0x20000240 = 5; *(uint8_t*)0x20000241 = 0xf; *(uint16_t*)0x20000242 = 0x2f; *(uint8_t*)0x20000244 = 3; *(uint8_t*)0x20000245 = 7; *(uint8_t*)0x20000246 = 0x10; *(uint8_t*)0x20000247 = 2; STORE_BY_BITMASK(uint32_t, , 0x20000248, 4, 0, 8); STORE_BY_BITMASK(uint32_t, , 0x20000249, 2, 0, 4); STORE_BY_BITMASK(uint32_t, , 0x20000249, 1, 4, 4); STORE_BY_BITMASK(uint32_t, , 0x2000024a, 0xb1c8, 0, 16); *(uint8_t*)0x2000024c = 3; *(uint8_t*)0x2000024d = 0x10; *(uint8_t*)0x2000024e = 0xb; *(uint8_t*)0x2000024f = 0x20; *(uint8_t*)0x20000250 = 0x10; *(uint8_t*)0x20000251 = 0xa; *(uint8_t*)0x20000252 = 6; STORE_BY_BITMASK(uint32_t, , 0x20000253, 5, 0, 5); STORE_BY_BITMASK(uint32_t, , 0x20000253, 1, 5, 27); *(uint16_t*)0x20000257 = 0xf008; *(uint16_t*)0x20000259 = 0xa9d; *(uint32_t*)0x2000025b = 0xc030; *(uint32_t*)0x2000025f = 0x3f00; *(uint32_t*)0x20000263 = 0xff000f; *(uint32_t*)0x20000267 = 0xf; *(uint32_t*)0x2000026b = 0x3f00; *(uint32_t*)0x200006d8 = 0xa; *(uint32_t*)0x200006dc = 4; *(uint64_t*)0x200006e0 = 0x20000280; *(uint8_t*)0x20000280 = 4; *(uint8_t*)0x20000281 = 3; *(uint16_t*)0x20000282 = 0x421; *(uint32_t*)0x200006e8 = 4; *(uint64_t*)0x200006ec = 0x200002c0; *(uint8_t*)0x200002c0 = 4; *(uint8_t*)0x200002c1 = 3; *(uint16_t*)0x200002c2 = 0x827; *(uint32_t*)0x200006f4 = 0x59; *(uint64_t*)0x200006f8 = 0x20000300; *(uint8_t*)0x20000300 = 0x59; *(uint8_t*)0x20000301 = 3; memcpy((void*)0x20000302, "\x5a\x83\x9a\xfc\x3f\x2d\xeb\x29\x31\x4e\x9d\xfe\xe5\xd0\x66\xc5" "\x79\x84\x4d\x68\xab\xb4\xba\x74\xf5\x67\x2b\x9e\x94\x18\x1d\xac" "\xbc\x44\x45\x8e\x1f\xba\xc7\xec\x9d\xc2\x96\xb0\xce\xdf\xac\xad" "\x11\x0c\x6b\x3b\x2f\x33\x49\x8c\x3c\x9f\x09\xf8\xf1\x19\x49\xcb" "\xf5\xcc\x37\x78\xbe\xfc\xc4\xe3\x73\x07\x68\xe6\x08\x69\x24\xcc" "\x84\x5b\x2d\x29\x46\xb1\xcb", 87); *(uint32_t*)0x20000700 = 4; *(uint64_t*)0x20000704 = 0x20000380; *(uint8_t*)0x20000380 = 4; *(uint8_t*)0x20000381 = 3; *(uint16_t*)0x20000382 = 0x401; *(uint32_t*)0x2000070c = 0x77; *(uint64_t*)0x20000710 = 0x200003c0; *(uint8_t*)0x200003c0 = 0x77; *(uint8_t*)0x200003c1 = 3; memcpy( (void*)0x200003c2, "\x94\xdd\x8e\x2a\xc5\xa5\x3d\x3b\xe2\x47\xba\xcf\x0e\x1b\xcc\x18\x7b" "\x9f\x05\x9c\x75\x34\xb9\xdc\x34\x06\x51\x51\x55\xcb\x12\xaa\x02\x99" "\x9e\x99\x8c\x30\xc4\xe0\x5a\x6f\x3b\x0b\xe9\x3d\xfb\x2c\x93\x50\x79" "\x79\x15\xe6\x6e\xfd\x94\x11\x6f\x19\xa8\x1f\xf1\x87\x99\x9e\x8b\x9c" "\xf6\x53\x1f\xa1\x04\xba\x50\xe6\x61\xae\xb4\x53\x76\xb4\xde\x5c\x6e" "\x9f\x24\x21\xdf\x01\x0a\xad\x0b\x36\xc3\xba\x87\x94\x29\x2c\x16\xb9" "\x7c\xf2\xbd\xcd\x38\x81\x9f\x97\x94\x80\xf6\x7b\xb3\x74\x60", 117); *(uint32_t*)0x20000718 = 0x102; *(uint64_t*)0x2000071c = 0x20000440; *(uint8_t*)0x20000440 = 2; *(uint8_t*)0x20000441 = 3; memcpy((void*)0x20000442, "\x33\x90\xb2\xf1\xba\xfd\x9d\xaf\xcc\x19\xd9\xa9\xa4\xc2\xa8\x51" "\xbc\xb0\xfd\x65\x87\x0d\xc2\xb3\xd4\x6a\x54\xef\xeb\x35\x54\x63" "\x72\x3d\x85\xea\x49\xbe\x5f\x64\x18\x9e\x39\x8c\xa0\x37\xaf\x9b" "\xf0\x8f\x44\xbc\x36\x22\xaf\xb6\xfc\x1d\xba\xc2\xf1\xb2\x5d\x3b" "\x20\xdb\x7f\x3a\xa8\x6c\xd2\x31\x22\x54\x46\xac\x61\x63\xbf\xa7" "\x3a\xa4\x24\xfa\xd1\xa8\x1a\x39\xa5\x0b\xf6\x89\x62\xec\x5b\x00" "\xdf\x38\xb1\x1f\xeb\xd2\x2d\xe7\xeb\x74\xb7\x1c\x33\x77\x09\xcd" "\xb0\x3a\x3e\xf8\x88\x22\x13\x28\x34\x92\x97\xe2\x36\xe3\xa6\x85" "\xd5\xf4\xd5\x64\xab\x94\x22\x8b\x20\x4e\xda\x37\x30\xa8\x24\x65" "\x64\x2d\x18\x23\xb1\x17\x3d\xe8\xad\xa4\xb8\x9f\x6d\x1e\xaf\xfa" "\x62\xc0\xfc\x1a\xf1\x90\x58\x95\x14\xe6\xc3\xb9\xcc\x23\x20\xe9" "\xc3\x9e\xf8\x7a\x54\xd9\x3c\xf4\x3e\x86\x35\xe4\x92\x1b\xbd\x2d" "\xf9\x20\x53\x8d\xb7\x07\x9b\xe3\x50\xb9\x27\x47\xf7\x2d\x43\x69" "\x39\x55\xac\x79\x5e\x12\x72\xb7\x04\xb8\x35\x25\x3e\xa6\x9e\xd7" "\x5c\x35\xfe\xdd\x4d\x69\x9f\xb9\xc9\x19\x9d\xbe\x3f\x6c\x65\x63" "\xc9\x96\xde\x13\xb2\x55\x9e\x80\x9d\xf6\x94\x56\x74\xdf\x38\x96", 256); *(uint32_t*)0x20000724 = 0; *(uint64_t*)0x20000728 = 0; *(uint32_t*)0x20000730 = 0; *(uint64_t*)0x20000734 = 0; *(uint32_t*)0x2000073c = 0; *(uint64_t*)0x20000740 = 0; *(uint32_t*)0x20000748 = 4; *(uint64_t*)0x2000074c = 0x20000680; *(uint8_t*)0x20000680 = 4; *(uint8_t*)0x20000681 = 3; *(uint16_t*)0x20000682 = 0xc1a; syz_usb_connect(7, 0x36, 0x200001c0, 0x200006c0); break; } } int main(void) { syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul, 0ul); for (procid = 0; procid < 6; procid++) { if (fork() == 0) { do_sandbox_none(); } } sleep(1000000); return 0; }