diff options
| author | Andrey Konovalov <andreyknvl@google.com> | 2019-08-22 19:53:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-22 19:53:52 +0200 |
| commit | ca6f3cfa782bb9aa9e1cb1247a2a4632608ab368 (patch) | |
| tree | f3bdb8f2e032820a269de2e2a99eb31e19a58f3b /sys/linux/vusb.txt | |
| parent | d003d6d021fcd38dfc3b578f1f179a76654bb709 (diff) | |
sys/linux: fix bNumEndpoints in a USB interface (#1360)
bNumEndpoints is defined as len[endpoints]. This initially assumed that
endpoints is an array, which is not the case for descriptions for
particular USB classes. Improve it by defining a new template for interfaces
and passing in a value range for bNumEndpoints for these cases.
Diffstat (limited to 'sys/linux/vusb.txt')
| -rw-r--r-- | sys/linux/vusb.txt | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sys/linux/vusb.txt b/sys/linux/vusb.txt index 7b03b8e5f..dde1db777 100644 --- a/sys/linux/vusb.txt +++ b/sys/linux/vusb.txt @@ -93,14 +93,13 @@ type usb_config_descriptor_t[NUM, ATTRS, IFS] { interfaces IFS } [packed] -type usb_interface_descriptor_t[IFNUM, ALTNUM, CLASS, SUBCLASS, PROTOCOL, EXTRA, EPS] { +type usb_interface_descriptor_t[IFNUM, ALTNUM, EPSNUM, CLASS, SUBCLASS, PROTOCOL, EXTRA, EPS] { bLength const[USB_DT_INTERFACE_SIZE, int8] bDescriptorType const[USB_DT_INTERFACE, int8] bInterfaceNumber IFNUM bAlternateSetting ALTNUM bNumEndpoints len[endpoints, int8] -# TODO: endpoints is not necessarily an array. bInterfaceClass CLASS bInterfaceSubClass SUBCLASS bInterfaceProtocol PROTOCOL @@ -110,6 +109,8 @@ type usb_interface_descriptor_t[IFNUM, ALTNUM, CLASS, SUBCLASS, PROTOCOL, EXTRA, endpoints EPS } [packed] +type usb_interface_descriptor_eps_array_t[IFNUM, ALTNUM, CLASS, SUBCLASS, PROTOCOL, EXTRA, EPS] usb_interface_descriptor_t[IFNUM, ALTNUM, len[endpoints, int8], CLASS, SUBCLASS, PROTOCOL, EXTRA, EPS] + # TODO: Some endpoints have USB_DT_ENDPOINT_SIZE. type usb_endpoint_descriptor_t[ADDR, ATTRS, EXTRA] { bLength const[USB_DT_ENDPOINT_AUDIO_SIZE, int8] @@ -149,7 +150,7 @@ usb_config_attributes = USB_CONFIG_ATT_ONE, USB_CONFIG_ATT_SELFPOWER, USB_CONFIG # bInterfaceNumber, bInterfaceClass, bInterfaceSubClass and bInterfaceProtocol # are patched by Go code, see sys/linux/init_vusb.go. usb_interface_descriptor { - inner usb_interface_descriptor_t[const[0, int8], int8, const[0, int8], const[0, int8], const[0, int8], array[usb_interface_extra_descriptor, 0:2], array[usb_endpoint_descriptor, 0:16]] + inner usb_interface_descriptor_eps_array_t[const[0, int8], int8, const[0, int8], const[0, int8], const[0, int8], array[usb_interface_extra_descriptor, 0:2], array[usb_endpoint_descriptor, 0:16]] } [packed] usb_endpoint_descriptor { @@ -518,7 +519,7 @@ usb_config_descriptor_hid { } [packed] usb_interface_descriptor_hid { - inner usb_interface_descriptor_t[const[0, int8], int8, const[USB_CLASS_HID, int8], const[USB_INTERFACE_SUBCLASS_BOOT, int8], flags[usb_hid_protocols, int8], usb_hid_descriptor_hid, usb_endpoint_descriptors_hid] + inner usb_interface_descriptor_t[const[0, int8], int8, int8[1:2], const[USB_CLASS_HID, int8], const[USB_INTERFACE_SUBCLASS_BOOT, int8], flags[usb_hid_protocols, int8], usb_hid_descriptor_hid, usb_endpoint_descriptors_hid] } [packed] usb_hid_protocols = 0, USB_INTERFACE_PROTOCOL_KEYBOARD, USB_INTERFACE_PROTOCOL_MOUSE @@ -652,7 +653,7 @@ usb_config_descriptor_printer { } [packed] usb_interface_descriptor_printer { - inner usb_interface_descriptor_t[const[0, int8], int8, const[USB_CLASS_PRINTER, int8], const[1, int8], int8[USBLP_FIRST_PROTOCOL:USBLP_LAST_PROTOCOL], void, usb_endpoint_descriptors_printer] + inner usb_interface_descriptor_t[const[0, int8], int8, int8[1:2], const[USB_CLASS_PRINTER, int8], const[1, int8], int8[USBLP_FIRST_PROTOCOL:USBLP_LAST_PROTOCOL], void, usb_endpoint_descriptors_printer] } [packed] usb_endpoint_descriptors_printer { @@ -725,7 +726,7 @@ usb_config_descriptor_cdc_ethernet { # Per specification CDC Ethernet devices have two interfaces (control and data), but we're merging # them into one, as Linux supports this, and syzkaller doesn't support multiple interfaces yet. usb_interface_descriptor_cdc_ethernet { - inner usb_interface_descriptor_t[const[0, int8], int8, const[USB_CLASS_COMM, int8], const[USB_CDC_SUBCLASS_ETHERNET, int8], const[USB_CDC_PROTO_NONE, int8], usb_cdc_header_ethernet, usb_endpoint_descriptors_cdc_ethernet] + inner usb_interface_descriptor_t[const[0, int8], int8, in8[2:3], const[USB_CLASS_COMM, int8], const[USB_CDC_SUBCLASS_ETHERNET, int8], const[USB_CDC_PROTO_NONE, int8], usb_cdc_header_ethernet, usb_endpoint_descriptors_cdc_ethernet] } [packed] usb_endpoint_descriptors_cdc_ethernet { @@ -968,7 +969,7 @@ usb_config_descriptor_cdc_ncm { } [packed] usb_interface_descriptor_cdc_ncm { - inner usb_interface_descriptor_t[const[0, int8], const[CDC_NCM_COMM_ALTSETTING_NCM, int8], const[USB_CLASS_COMM, int8], const[USB_CDC_SUBCLASS_NCM, int8], const[USB_CDC_PROTO_NONE, int8], usb_cdc_header_ncm, usb_endpoint_descriptors_cdc_ethernet] + inner usb_interface_descriptor_t[const[0, int8], const[CDC_NCM_COMM_ALTSETTING_NCM, int8], int8[2:3], const[USB_CLASS_COMM, int8], const[USB_CDC_SUBCLASS_NCM, int8], const[USB_CDC_PROTO_NONE, int8], usb_cdc_header_ncm, usb_endpoint_descriptors_cdc_ethernet] } [packed] # https://elixir.bootlin.com/linux/v5.2.7/source/drivers/usb/core/message.c#L2137 |
