map[SimplifiedCRepro:// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/usb/ch9.h>
static unsigned long long procid;
static void sleep_ms(uint64_t ms)
{
usleep(ms * 1000);
}
#define MAX_FDS 30
#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 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;
}
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;
}
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,
struct usb_qualifier_descriptor* qual,
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) {
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_data = (char*)qual;
*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);
#define ATH9K_FIRMWARE_DOWNLOAD 0x30
#define ATH9K_FIRMWARE_DOWNLOAD_COMP 0x31
static bool lookup_connect_response_out_ath9k(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:
return true;
default:
break;
}
break;
case USB_TYPE_VENDOR:
switch (ctrl->bRequest) {
case ATH9K_FIRMWARE_DOWNLOAD:
return true;
case ATH9K_FIRMWARE_DOWNLOAD_COMP:
*done = true;
return true;
default:
break;
}
break;
}
return false;
}
#define UDC_NAME_LENGTH_MAX 128
struct usb_raw_init {
__u8 driver_name[UDC_NAME_LENGTH_MAX];
__u8 device_name[UDC_NAME_LENGTH_MAX];
__u8 speed;
};
enum usb_raw_event_type {
USB_RAW_EVENT_INVALID = 0,
USB_RAW_EVENT_CONNECT = 1,
USB_RAW_EVENT_CONTROL = 2,
};
struct usb_raw_event {
__u32 type;
__u32 length;
__u8 data[0];
};
struct usb_raw_ep_io {
__u16 ep;
__u16 flags;
__u32 length;
__u8 data[0];
};
#define USB_RAW_EPS_NUM_MAX 30
#define USB_RAW_EP_NAME_MAX 16
#define USB_RAW_EP_ADDR_ANY 0xff
struct usb_raw_ep_caps {
__u32 type_control : 1;
__u32 type_iso : 1;
__u32 type_bulk : 1;
__u32 type_int : 1;
__u32 dir_in : 1;
__u32 dir_out : 1;
};
struct usb_raw_ep_limits {
__u16 maxpacket_limit;
__u16 max_streams;
__u32 reserved;
};
struct usb_raw_ep_info {
__u8 name[USB_RAW_EP_NAME_MAX];
__u32 addr;
struct usb_raw_ep_caps caps;
struct usb_raw_ep_limits limits;
};
struct usb_raw_eps_info {
struct usb_raw_ep_info eps[USB_RAW_EPS_NUM_MAX];
};
#define USB_RAW_IOCTL_INIT _IOW('U', 0, struct usb_raw_init)
#define USB_RAW_IOCTL_RUN _IO('U', 1)
#define USB_RAW_IOCTL_EVENT_FETCH _IOR('U', 2, struct usb_raw_event)
#define USB_RAW_IOCTL_EP0_WRITE _IOW('U', 3, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP0_READ _IOWR('U', 4, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_ENABLE _IOW('U', 5, struct usb_endpoint_descriptor)
#define USB_RAW_IOCTL_EP_DISABLE _IOW('U', 6, __u32)
#define USB_RAW_IOCTL_EP_WRITE _IOW('U', 7, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_EP_READ _IOWR('U', 8, struct usb_raw_ep_io)
#define USB_RAW_IOCTL_CONFIGURE _IO('U', 9)
#define USB_RAW_IOCTL_VBUS_DRAW _IOW('U', 10, __u32)
#define USB_RAW_IOCTL_EPS_INFO _IOR('U', 11, struct usb_raw_eps_info)
#define USB_RAW_IOCTL_EP0_STALL _IO('U', 12)
#define USB_RAW_IOCTL_EP_SET_HALT _IOW('U', 13, __u32)
#define USB_RAW_IOCTL_EP_CLEAR_HALT _IOW('U', 14, __u32)
#define USB_RAW_IOCTL_EP_SET_WEDGE _IOW('U', 15, __u32)
static int usb_raw_open()
{
return open("/dev/raw-gadget", O_RDWR);
}
static int usb_raw_init(int fd, uint32_t speed, const char* driver, const char* device)
{
struct usb_raw_init arg;
strncpy((char*)&arg.driver_name[0], driver, sizeof(arg.driver_name));
strncpy((char*)&arg.device_name[0], device, sizeof(arg.device_name));
arg.speed = speed;
return ioctl(fd, USB_RAW_IOCTL_INIT, &arg);
}
static int usb_raw_run(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_RUN, 0);
}
static int usb_raw_ep_write(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP_WRITE, io);
}
static int usb_raw_configure(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_CONFIGURE, 0);
}
static int usb_raw_vbus_draw(int fd, uint32_t power)
{
return ioctl(fd, USB_RAW_IOCTL_VBUS_DRAW, power);
}
static int usb_raw_ep0_write(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_WRITE, io);
}
static int usb_raw_ep0_read(int fd, struct usb_raw_ep_io* io)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_READ, io);
}
static int usb_raw_event_fetch(int fd, struct usb_raw_event* event)
{
return ioctl(fd, USB_RAW_IOCTL_EVENT_FETCH, event);
}
static int usb_raw_ep_enable(int fd, struct usb_endpoint_descriptor* desc)
{
return ioctl(fd, USB_RAW_IOCTL_EP_ENABLE, desc);
}
static int usb_raw_ep_disable(int fd, int ep)
{
return ioctl(fd, USB_RAW_IOCTL_EP_DISABLE, ep);
}
static int usb_raw_ep0_stall(int fd)
{
return ioctl(fd, USB_RAW_IOCTL_EP0_STALL, 0);
}
static int lookup_endpoint(int fd, uint8_t bEndpointAddress)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return -1;
if (index->iface_cur < 0)
return -1;
for (int ep = 0; ep < index->ifaces[index->iface_cur].eps_num; ep++)
if (index->ifaces[index->iface_cur].eps[ep].desc.bEndpointAddress == bEndpointAddress)
return index->ifaces[index->iface_cur].eps[ep].handle;
return -1;
}
#define USB_MAX_PACKET_SIZE 4096
struct usb_raw_control_event {
struct usb_raw_event inner;
struct usb_ctrlrequest ctrl;
char data[USB_MAX_PACKET_SIZE];
};
struct usb_raw_ep_io_data {
struct usb_raw_ep_io inner;
char data[USB_MAX_PACKET_SIZE];
};
static void set_interface(int fd, int n)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return;
if (index->iface_cur >= 0 && index->iface_cur < index->ifaces_num) {
for (int ep = 0; ep < index->ifaces[index->iface_cur].eps_num; ep++) {
int rv = usb_raw_ep_disable(fd, index->ifaces[index->iface_cur].eps[ep].handle);
if (rv < 0) {
} else {
}
}
}
if (n >= 0 && n < index->ifaces_num) {
for (int ep = 0; ep < index->ifaces[n].eps_num; ep++) {
int rv = usb_raw_ep_enable(fd, &index->ifaces[n].eps[ep].desc);
if (rv < 0) {
} else {
index->ifaces[n].eps[ep].handle = rv;
}
}
index->iface_cur = n;
}
}
static int configure_device(int fd)
{
struct usb_device_index* index = lookup_usb_index(fd);
if (!index)
return -1;
int rv = usb_raw_vbus_draw(fd, index->bMaxPower);
if (rv < 0) {
return rv;
}
rv = usb_raw_configure(fd);
if (rv < 0) {
return rv;
}
set_interface(fd, 0);
return 0;
}
static volatile long syz_usb_connect_impl(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)
{
if (!dev) {
return -1;
}
int fd = usb_raw_open();
if (fd < 0) {
return fd;
}
if (fd >= MAX_FDS) {
close(fd);
return -1;
}
struct usb_device_index* index = add_usb_index(fd, dev, dev_len);
if (!index) {
return -1;
}
char device[32];
sprintf(&device[0], "dummy_udc.%llu", procid);
int rv = usb_raw_init(fd, speed, "dummy_udc", &device[0]);
if (rv < 0) {
return rv;
}
rv = usb_raw_run(fd);
if (rv < 0) {
return rv;
}
bool done = false;
while (!done) {
struct usb_raw_control_event event;
event.inner.type = 0;
event.inner.length = sizeof(event.ctrl);
rv = usb_raw_event_fetch(fd, (struct usb_raw_event*)&event);
if (rv < 0) {
return rv;
}
if (event.inner.type != USB_RAW_EVENT_CONTROL)
continue;
char* response_data = NULL;
uint32_t response_length = 0;
struct usb_qualifier_descriptor qual;
if (event.ctrl.bRequestType & USB_DIR_IN) {
if (!lookup_connect_response_in(fd, descs, &event.ctrl, &qual, &response_data, &response_length)) {
usb_raw_ep0_stall(fd);
continue;
}
} else {
if (!lookup_connect_response_out(fd, descs, &event.ctrl, &done)) {
usb_raw_ep0_stall(fd);
continue;
}
response_data = NULL;
response_length = event.ctrl.wLength;
}
if ((event.ctrl.bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD &&
event.ctrl.bRequest == USB_REQ_SET_CONFIGURATION) {
rv = configure_device(fd);
if (rv < 0) {
return rv;
}
}
struct usb_raw_ep_io_data response;
response.inner.ep = 0;
response.inner.flags = 0;
if (response_length > sizeof(response.data))
response_length = 0;
if (event.ctrl.wLength < response_length)
response_length = event.ctrl.wLength;
response.inner.length = response_length;
if (response_data)
memcpy(&response.data[0], response_data, response_length);
else
memset(&response.data[0], 0, response_length);
if (event.ctrl.bRequestType & USB_DIR_IN) {
rv = usb_raw_ep0_write(fd, (struct usb_raw_ep_io*)&response);
} else {
rv = usb_raw_ep0_read(fd, (struct usb_raw_ep_io*)&response);
}
if (rv < 0) {
return rv;
}
}
sleep_ms(200);
return fd;
}
static volatile long syz_usb_connect_ath9k(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;
return syz_usb_connect_impl(speed, dev_len, dev, descs, &lookup_connect_response_out_ath9k);
}
static volatile long syz_usb_ep_write(volatile long a0, volatile long a1, volatile long a2, volatile long a3)
{
int fd = a0;
uint8_t ep = a1;
uint32_t len = a2;
char* data = (char*)a3;
int ep_handle = lookup_endpoint(fd, ep);
if (ep_handle < 0) {
return -1;
}
struct usb_raw_ep_io_data io_data;
io_data.inner.ep = ep_handle;
io_data.inner.flags = 0;
if (len > sizeof(io_data.data))
len = sizeof(io_data.data);
io_data.inner.length = len;
memcpy(&io_data.data[0], data, len);
int rv = usb_raw_ep_write(fd, (struct usb_raw_ep_io*)&io_data);
if (rv < 0) {
return rv;
}
sleep_ms(200);
return 0;
}
static long syz_open_dev(volatile long a0, volatile long a1, volatile long a2)
{
if (a0 == 0xc || a0 == 0xb) {
char buf[128];
sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1, (uint8_t)a2);
return open(buf, O_RDWR, 0);
} else {
unsigned long nb = a1;
char buf[1024];
char* hash;
strncpy(buf, (char*)a0, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = 0;
while ((hash = strchr(buf, '#'))) {
*hash = '0' + (char)(nb % 10);
nb /= 10;
}
return open(buf, a2 & ~O_CREAT, 0);
}
}
uint64_t r[7] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
intptr_t res = 0;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// socket$packet arguments: [
// domain: const = 0x11 (8 bytes)
// type: packet_socket_type = 0x2 (8 bytes)
// proto: const = 0x300 (4 bytes)
// ]
// returns sock_packet
res = syscall(__NR_socket, /*domain=*/0x11ul, /*type=SOCK_DGRAM*/2ul, /*proto=*/0x300);
if (res != -1)
r[0] = res;
// setsockopt$packet_int arguments: [
// fd: sock_packet (resource)
// level: const = 0x107 (4 bytes)
// optname: packet_option_types_int = 0xa (4 bytes)
// optval: ptr[in, int32] {
// int32 = 0x2 (4 bytes)
// }
// optlen: len = 0x4 (8 bytes)
// ]
*(uint32_t*)0x200000000080 = 2;
syscall(__NR_setsockopt, /*fd=*/r[0], /*level=*/0x107, /*optname=PACKET_VERSION*/0xa, /*optval=*/0x200000000080ul, /*optlen=*/4ul);
// setsockopt$packet_rx_ring arguments: [
// fd: sock_packet (resource)
// level: const = 0x107 (4 bytes)
// optname: const = 0x5 (4 bytes)
// optval: ptr[in, tpacket_req_u] {
// union tpacket_req_u {
// req3: tpacket_req3 {
// tp_block_size: int32 = 0x1000 (4 bytes)
// tp_block_nr: int32 = 0x3a (4 bytes)
// tp_frame_size: int32 = 0x1000 (4 bytes)
// tp_frame_nr: int32 = 0x3a (4 bytes)
// tp_retire_blk_tov: int32 = 0x7ff (4 bytes)
// tp_sizeof_priv: int32 = 0xf83 (4 bytes)
// tp_feature_req_word: int32 = 0x3 (4 bytes)
// }
// }
// }
// optlen: len = 0x1c (8 bytes)
// ]
*(uint32_t*)0x200000000180 = 0x1000;
*(uint32_t*)0x200000000184 = 0x3a;
*(uint32_t*)0x200000000188 = 0x1000;
*(uint32_t*)0x20000000018c = 0x3a;
*(uint32_t*)0x200000000190 = 0x7ff;
*(uint32_t*)0x200000000194 = 0xf83;
*(uint32_t*)0x200000000198 = 3;
syscall(__NR_setsockopt, /*fd=*/r[0], /*level=*/0x107, /*optname=*/5, /*optval=*/0x200000000180ul, /*optlen=*/0x1cul);
// socket$packet arguments: [
// domain: const = 0x11 (8 bytes)
// type: packet_socket_type = 0x2 (8 bytes)
// proto: const = 0x300 (4 bytes)
// ]
// returns sock_packet
res = syscall(__NR_socket, /*domain=*/0x11ul, /*type=SOCK_DGRAM*/2ul, /*proto=*/0x300);
if (res != -1)
r[1] = res;
// openat$rdma_cm arguments: [
// fd: const = 0xffffffffffffff9c (8 bytes)
// file: ptr[in, buffer] {
// buffer: {2f 64 65 76 2f 69 6e 66 69 6e 69 62 61 6e 64 2f 72 64 6d 61 5f 63 6d 00} (length 0x18)
// }
// flags: const = 0x2 (4 bytes)
// mode: const = 0x0 (2 bytes)
// ]
// returns fd_rdma_cm
memcpy((void*)0x200000000000, "/dev/infiniband/rdma_cm\000", 24);
syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x200000000000ul, /*flags=*/2, /*mode=*/0);
// syz_usb_connect_ath9k arguments: [
// speed: const = 0x3 (8 bytes)
// dev_len: len = 0x7c (8 bytes)
// dev: ptr[in, usb_device_descriptor_ath9k] {
// usb_device_descriptor_ath9k {
// inner: usb_device_descriptor_verbose_t[const[0x200, int16], USB_CLASS_VENDOR_SPEC, USB_SUBCLASS_VENDOR_SPEC, 0xff, const[64, int8], 0xcf3, 0x9271, 0x108, array[usb_config_descriptor_ath9k, 1]] {
// bLength: const = 0x12 (1 bytes)
// bDescriptorType: const = 0x1 (1 bytes)
// bcdUSB: const = 0x200 (2 bytes)
// bDeviceClass: const = 0xff (1 bytes)
// bDeviceSubClass: const = 0xff (1 bytes)
// bDeviceProtocol: const = 0xff (1 bytes)
// bMaxPacketSize0: const = 0x40 (1 bytes)
// idVendor: const = 0xcf3 (2 bytes)
// idProduct: const = 0x9271 (2 bytes)
// bcdDevice: const = 0x108 (2 bytes)
// iManufacturer: const = 0x1 (1 bytes)
// iProduct: const = 0x2 (1 bytes)
// iSerialNumber: const = 0x3 (1 bytes)
// bNumConfigurations: len = 0x38e3643 (1 bytes)
// configs: array[usb_config_descriptor_ath9k] {
// usb_config_descriptor_ath9k {
// inner: usb_config_descriptor_verbose_t[const[1, int8], const[1, int8], const[0, int8], const[USB_CONFIG_ATT_ONE, int8], const[250, int8], void, usb_interface_descriptor_ath9k] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x2 (1 bytes)
// wTotalLength: len = 0x48 (2 bytes)
// bNumInterfaces: const = 0x1 (1 bytes)
// bConfigurationValue: const = 0x1 (1 bytes)
// iConfiguration: const = 0x0 (1 bytes)
// bmAttributes: const = 0x80 (1 bytes)
// bMaxPower: const = 0xfa (1 bytes)
// extra: buffer: {} (length 0x0)
// interfaces: usb_interface_descriptor_ath9k {
// iface: usb_interface_descriptor_verbose_t[const[0, int8], const[0, int8], const[6, int8], const[USB_CLASS_VENDOR_SPEC, int8], const[0, int8], const[0, int8], const[0, int8], void, usb_endpoint_descriptors_ath9k] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x4 (1 bytes)
// bInterfaceNumber: const = 0x0 (1 bytes)
// bAlternateSetting: const = 0x0 (1 bytes)
// bNumEndpoints: const = 0x6 (1 bytes)
// bInterfaceClass: const = 0xff (1 bytes)
// bInterfaceSubClass: const = 0x0 (1 bytes)
// bInterfaceProtocol: const = 0x0 (1 bytes)
// iInterface: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// endpoints: usb_endpoint_descriptors_ath9k {
// bulk_out: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_OUT_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x1 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// bulk_in: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_IN_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x82 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// int_in: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_INT_IN_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_INT_ATTRIBUTES, int8], const[64, int16], const[1, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x83 (1 bytes)
// bmAttributes: const = 0x3 (1 bytes)
// wMaxPacketSize: const = 0x40 (2 bytes)
// bInterval: const = 0x1 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// int_out: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_INT_OUT_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_INT_ATTRIBUTES, int8], const[64, int16], const[1, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x4 (1 bytes)
// bmAttributes: const = 0x3 (1 bytes)
// wMaxPacketSize: const = 0x40 (2 bytes)
// bInterval: const = 0x1 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// bulk_extra1: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_EXTRA1_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x5 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// bulk_extra2: usb_endpoint_descriptor_verbose_t[const[USB_ENDPOINT_ATH9K_BULK_EXTRA2_ADDRESS, int8], const[USB_ENDPOINT_ATH9K_BULK_ATTRIBUTES, int8], const[512, int16], const[0, int8], const[0, int8], const[0, int8], void] {
// bLength: const = 0x9 (1 bytes)
// bDescriptorType: const = 0x5 (1 bytes)
// bEndpointAddress: const = 0x6 (1 bytes)
// bmAttributes: const = 0x2 (1 bytes)
// wMaxPacketSize: const = 0x200 (2 bytes)
// bInterval: const = 0x0 (1 bytes)
// bRefresh: const = 0x0 (1 bytes)
// bSynchAddress: const = 0x0 (1 bytes)
// extra: buffer: {} (length 0x0)
// }
// }
// }
// }
// }
// }
// }
// }
// }
// }
// conn_descs: const = 0x0 (8 bytes)
// ]
// returns fd_usb_ath9k
*(uint8_t*)0x200000000c80 = 0x12;
*(uint8_t*)0x200000000c81 = 1;
*(uint16_t*)0x200000000c82 = 0x200;
*(uint8_t*)0x200000000c84 = -1;
*(uint8_t*)0x200000000c85 = -1;
*(uint8_t*)0x200000000c86 = -1;
*(uint8_t*)0x200000000c87 = 0x40;
*(uint16_t*)0x200000000c88 = 0xcf3;
*(uint16_t*)0x200000000c8a = 0x9271;
*(uint16_t*)0x200000000c8c = 0x108;
*(uint8_t*)0x200000000c8e = 1;
*(uint8_t*)0x200000000c8f = 2;
*(uint8_t*)0x200000000c90 = 3;
*(uint8_t*)0x200000000c91 = 0x43;
*(uint8_t*)0x200000000c92 = 9;
*(uint8_t*)0x200000000c93 = 2;
*(uint16_t*)0x200000000c94 = 0x48;
*(uint8_t*)0x200000000c96 = 1;
*(uint8_t*)0x200000000c97 = 1;
*(uint8_t*)0x200000000c98 = 0;
*(uint8_t*)0x200000000c99 = 0x80;
*(uint8_t*)0x200000000c9a = 0xfa;
*(uint8_t*)0x200000000c9b = 9;
*(uint8_t*)0x200000000c9c = 4;
*(uint8_t*)0x200000000c9d = 0;
*(uint8_t*)0x200000000c9e = 0;
*(uint8_t*)0x200000000c9f = 6;
*(uint8_t*)0x200000000ca0 = -1;
*(uint8_t*)0x200000000ca1 = 0;
*(uint8_t*)0x200000000ca2 = 0;
*(uint8_t*)0x200000000ca3 = 0;
*(uint8_t*)0x200000000ca4 = 9;
*(uint8_t*)0x200000000ca5 = 5;
*(uint8_t*)0x200000000ca6 = 1;
*(uint8_t*)0x200000000ca7 = 2;
*(uint16_t*)0x200000000ca8 = 0x200;
*(uint8_t*)0x200000000caa = 0;
*(uint8_t*)0x200000000cab = 0;
*(uint8_t*)0x200000000cac = 0;
*(uint8_t*)0x200000000cad = 9;
*(uint8_t*)0x200000000cae = 5;
*(uint8_t*)0x200000000caf = 0x82;
*(uint8_t*)0x200000000cb0 = 2;
*(uint16_t*)0x200000000cb1 = 0x200;
*(uint8_t*)0x200000000cb3 = 0;
*(uint8_t*)0x200000000cb4 = 0;
*(uint8_t*)0x200000000cb5 = 0;
*(uint8_t*)0x200000000cb6 = 9;
*(uint8_t*)0x200000000cb7 = 5;
*(uint8_t*)0x200000000cb8 = 0x83;
*(uint8_t*)0x200000000cb9 = 3;
*(uint16_t*)0x200000000cba = 0x40;
*(uint8_t*)0x200000000cbc = 1;
*(uint8_t*)0x200000000cbd = 0;
*(uint8_t*)0x200000000cbe = 0;
*(uint8_t*)0x200000000cbf = 9;
*(uint8_t*)0x200000000cc0 = 5;
*(uint8_t*)0x200000000cc1 = 4;
*(uint8_t*)0x200000000cc2 = 3;
*(uint16_t*)0x200000000cc3 = 0x40;
*(uint8_t*)0x200000000cc5 = 1;
*(uint8_t*)0x200000000cc6 = 0;
*(uint8_t*)0x200000000cc7 = 0;
*(uint8_t*)0x200000000cc8 = 9;
*(uint8_t*)0x200000000cc9 = 5;
*(uint8_t*)0x200000000cca = 5;
*(uint8_t*)0x200000000ccb = 2;
*(uint16_t*)0x200000000ccc = 0x200;
*(uint8_t*)0x200000000cce = 0;
*(uint8_t*)0x200000000ccf = 0;
*(uint8_t*)0x200000000cd0 = 0;
*(uint8_t*)0x200000000cd1 = 9;
*(uint8_t*)0x200000000cd2 = 5;
*(uint8_t*)0x200000000cd3 = 6;
*(uint8_t*)0x200000000cd4 = 2;
*(uint16_t*)0x200000000cd5 = 0x200;
*(uint8_t*)0x200000000cd7 = 0;
*(uint8_t*)0x200000000cd8 = 0;
*(uint8_t*)0x200000000cd9 = 0;
res = -1;
res = syz_usb_connect_ath9k(/*speed=*/3, /*dev_len=*/0x7c, /*dev=*/0x200000000c80, /*conn_descs=*/0);
if (res != -1)
r[2] = res;
// syz_usb_ep_write$ath9k_ep2 arguments: [
// fd: fd_usb_ath9k (resource)
// ep: const = 0x83 (1 bytes)
// len: bytesize = 0x0 (8 bytes)
// data: nil
// ]
syz_usb_ep_write(/*fd=*/r[2], /*ep=*/0x83, /*len=*/0, /*data=*/0);
// syz_usb_ep_write$ath9k_ep1 arguments: [
// fd: fd_usb_ath9k (resource)
// ep: const = 0x82 (1 bytes)
// len: bytesize = 0x10 (8 bytes)
// data: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {0c 00 00 4e 15} (length 0x5)
// }
// }
// }
// ]
memcpy((void*)0x200000000000, "\x0c\x00\x00\x4e\x15", 5);
syz_usb_ep_write(/*fd=*/r[2], /*ep=*/0x82, /*len=*/0x10, /*data=*/0x200000000000);
// setsockopt$packet_int arguments: [
// fd: sock_packet (resource)
// level: const = 0x107 (4 bytes)
// optname: packet_option_types_int = 0xa (4 bytes)
// optval: ptr[in, int32] {
// int32 = 0x2 (4 bytes)
// }
// optlen: len = 0x4 (8 bytes)
// ]
*(uint32_t*)0x200000000080 = 2;
syscall(__NR_setsockopt, /*fd=*/r[1], /*level=*/0x107, /*optname=PACKET_VERSION*/0xa, /*optval=*/0x200000000080ul, /*optlen=*/4ul);
// syz_open_dev$radio arguments: [
// dev: ptr[in, buffer] {
// buffer: {2f 64 65 76 2f 72 61 64 69 6f 23 00} (length 0xc)
// }
// id: proc = 0x3 (8 bytes)
// flags: const = 0x2 (8 bytes)
// ]
// returns fd_video
memcpy((void*)0x200000000040, "/dev/radio#\000", 12);
res = -1;
res = syz_open_dev(/*dev=*/0x200000000040, /*id=*/3, /*flags=*/2);
if (res != -1)
r[3] = res;
// ioctl$VIDIOC_S_MODULATOR arguments: [
// fd: fd_video (resource)
// cmd: const = 0x40445637 (4 bytes)
// arg: ptr[in, v4l2_modulator] {
// v4l2_modulator {
// index: int32 = 0x6 (4 bytes)
// name: buffer: {63 8d 0b d9 30 b4 9e 09 dd 70 d2 99 9e 07 1c 91 29 be e8 a8 11 27 29 44 f0 3d 49 a6 f9 4f 00 71} (length 0x20)
// capability: v4l2_tuner_capability = 0x0 (4 bytes)
// rangelow: int32 = 0x0 (4 bytes)
// rangehigh: int32 = 0x0 (4 bytes)
// txsubchans: v4l2_tuner_rxsubchans = 0x0 (4 bytes)
// type: v4l2_tuner_type = 0x0 (4 bytes)
// reserved: buffer: {00 00 00 00 00 00 00 00 00 00 00 00} (length 0xc)
// }
// }
// ]
*(uint32_t*)0x200000000080 = 6;
memcpy((void*)0x200000000084, "... [truncated large byte array] ...", 32);
*(uint32_t*)0x2000000000a4 = 0;
*(uint32_t*)0x2000000000a8 = 0;
*(uint32_t*)0x2000000000ac = 0;
*(uint32_t*)0x2000000000b0 = 0;
*(uint32_t*)0x2000000000b4 = 0;
memset((void*)0x2000000000b8, 0, 12);
syscall(__NR_ioctl, /*fd=*/r[3], /*cmd=*/0x40445637, /*arg=*/0x200000000080ul);
// ioctl$VIDIOC_QUERYSTD arguments: [
// fd: fd_video (resource)
// cmd: const = 0x8008563f (4 bytes)
// arg: ptr[out, v4l2_std_id] {
// v4l2_std_id = 0x0 (8 bytes)
// }
// ]
syscall(__NR_ioctl, /*fd=*/r[3], /*cmd=*/0x8008563f, /*arg=*/0x200000000000ul);
// setsockopt$packet_rx_ring arguments: [
// fd: sock_packet (resource)
// level: const = 0x107 (4 bytes)
// optname: const = 0x5 (4 bytes)
// optval: ptr[in, tpacket_req_u] {
// union tpacket_req_u {
// req3: tpacket_req3 {
// tp_block_size: int32 = 0x1000 (4 bytes)
// tp_block_nr: int32 = 0x3a (4 bytes)
// tp_frame_size: int32 = 0x1000 (4 bytes)
// tp_frame_nr: int32 = 0x3a (4 bytes)
// tp_retire_blk_tov: int32 = 0x7ff (4 bytes)
// tp_sizeof_priv: int32 = 0xf83 (4 bytes)
// tp_feature_req_word: int32 = 0x3 (4 bytes)
// }
// }
// }
// optlen: len = 0x1c (8 bytes)
// ]
*(uint32_t*)0x200000000180 = 0x1000;
*(uint32_t*)0x200000000184 = 0x3a;
*(uint32_t*)0x200000000188 = 0x1000;
*(uint32_t*)0x20000000018c = 0x3a;
*(uint32_t*)0x200000000190 = 0x7ff;
*(uint32_t*)0x200000000194 = 0xf83;
*(uint32_t*)0x200000000198 = 3;
syscall(__NR_setsockopt, /*fd=*/r[1], /*level=*/0x107, /*optname=*/5, /*optval=*/0x200000000180ul, /*optlen=*/0x1cul);
// socket$packet arguments: [
// domain: const = 0x11 (8 bytes)
// type: packet_socket_type = 0x2 (8 bytes)
// proto: const = 0x300 (4 bytes)
// ]
// returns sock_packet
res = syscall(__NR_socket, /*domain=*/0x11ul, /*type=SOCK_DGRAM*/2ul, /*proto=*/0x300);
if (res != -1)
r[4] = res;
// socket$packet arguments: [
// domain: const = 0x11 (8 bytes)
// type: packet_socket_type = 0x2 (8 bytes)
// proto: const = 0x300 (4 bytes)
// ]
// returns sock_packet
res = syscall(__NR_socket, /*domain=*/0x11ul, /*type=SOCK_DGRAM*/2ul, /*proto=*/0x300);
if (res != -1)
r[5] = res;
// ioctl$sock_SIOCGIFINDEX arguments: [
// fd: sock (resource)
// cmd: const = 0x8933 (4 bytes)
// arg: ptr[out, ifreq_dev_t[devnames, ifindex]] {
// ifreq_dev_t[devnames, ifindex] {
// ifr_ifrn: buffer: {76 6c 61 6e 30 00 00 00 00 00 00 00 00 00 00 00} (length 0x10)
// elem: ifindex (resource)
// pad = 0x0 (20 bytes)
// }
// }
// ]
memcpy((void*)0x200000000340, "vlan0\000\000\000\000\000\000\000\000\000\000\000", 16);
res = syscall(__NR_ioctl, /*fd=*/r[4], /*cmd=*/0x8933, /*arg=*/0x200000000340ul);
if (res != -1)
r[6] = *(uint32_t*)0x200000000350;
// sendto$packet arguments: [
// fd: sock_packet (resource)
// buf: ptr[in, buffer] {
// buffer: {} (length 0x0)
// }
// len: len = 0x0 (8 bytes)
// f: send_flags = 0x4004 (8 bytes)
// addr: ptr[in, sockaddr_ll] {
// sockaddr_ll {
// sll_family: const = 0x11 (2 bytes)
// sll_protocol: packet_protocols = 0x8100 (2 bytes)
// sll_ifindex: ifindex (resource)
// sll_hatype: const = 0x1 (2 bytes)
// sll_pkttype: int8 = 0xe0 (1 bytes)
// sll_halen: const = 0x6 (1 bytes)
// sll_addr: union mac_addr {
// empty: buffer: {00 00 00 00 00 00} (length 0x6)
// }
// pad: buffer: {00 00} (length 0x2)
// }
// }
// addrlen: len = 0x14 (8 bytes)
// ]
*(uint16_t*)0x200000000200 = 0x11;
*(uint16_t*)0x200000000202 = htobe16(0x8100);
*(uint32_t*)0x200000000204 = r[6];
*(uint16_t*)0x200000000208 = 1;
*(uint8_t*)0x20000000020a = 0xe0;
*(uint8_t*)0x20000000020b = 6;
memset((void*)0x20000000020c, 0, 6);
memset((void*)0x200000000212, 0, 2);
syscall(__NR_sendto, /*fd=*/r[5], /*buf=*/0x200000000400ul, /*len=*/0ul, /*f=MSG_NOSIGNAL|MSG_DONTROUTE*/0x4004ul, /*addr=*/0x200000000200ul, /*addrlen=*/0x14ul);
return 0;
}
]