github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/linux/dev_bus_usb.txt (about) 1 # Copyright 2019 syzkaller project authors. All rights reserved. 2 # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 # https://elixir.bootlin.com/linux/latest/source/drivers/usb/core/devio.c 5 6 include <linux/ioctl.h> 7 include <linux/usb.h> 8 include <linux/usbdevice_fs.h> 9 include <uapi/linux/fcntl.h> 10 include <uapi/linux/usb/ch9.h> 11 12 define MAXDRIVERNAME USBDEVFS_MAXDRIVERNAME + 1 13 14 resource fd_usbfs[fd] 15 16 syz_open_dev$usbfs(dev ptr[in, string["/dev/bus/usb/00#/00#"]], id intptr, flags flags[open_flags]) fd_usbfs 17 18 read$usbfs(fd fd_usbfs, buf buffer[out], count len[buf]) 19 20 mmap$usbfs(addr vma, len len[addr], prot flags[mmap_prot], flags flags[mmap_flags], fd fd_usbfs, offset fileoff) 21 _ = __NR_mmap2 22 23 # TODO: arg is a pointer to a previously submitted URB. 24 ioctl$USBDEVFS_REAPURB(fd fd_usbfs, cmd const[USBDEVFS_REAPURB], arg ptr[out, int64]) 25 ioctl$USBDEVFS_REAPURBNDELAY(fd fd_usbfs, cmd const[USBDEVFS_REAPURBNDELAY], arg ptr[out, int64]) 26 27 ioctl$USBDEVFS_CONTROL(fd fd_usbfs, cmd const[USBDEVFS_CONTROL], arg ptr[in, usbdevfs_ctrltransfer]) 28 ioctl$USBDEVFS_BULK(fd fd_usbfs, cmd const[USBDEVFS_BULK], arg ptr[in, usbdevfs_bulktransfer]) 29 ioctl$USBDEVFS_RESETEP(fd fd_usbfs, cmd const[USBDEVFS_RESETEP], arg ptr[in, usbdevfs_ep]) 30 ioctl$USBDEVFS_RESET(fd fd_usbfs, cmd const[USBDEVFS_RESET]) 31 ioctl$USBDEVFS_CLEAR_HALT(fd fd_usbfs, cmd const[USBDEVFS_CLEAR_HALT], arg ptr[in, usbdevfs_ep]) 32 ioctl$USBDEVFS_GETDRIVER(fd fd_usbfs, cmd const[USBDEVFS_GETDRIVER], arg ptr[inout, usbdevfs_getdriver]) 33 ioctl$USBDEVFS_CONNECTINFO(fd fd_usbfs, cmd const[USBDEVFS_CONNECTINFO], arg ptr[out, usbdevfs_connectinfo]) 34 ioctl$USBDEVFS_SETINTERFACE(fd fd_usbfs, cmd const[USBDEVFS_SETINTERFACE], arg ptr[in, usbdevfs_setinterface]) 35 ioctl$USBDEVFS_SETCONFIGURATION(fd fd_usbfs, cmd const[USBDEVFS_SETCONFIGURATION], arg ptr[in, int32]) 36 ioctl$USBDEVFS_SUBMITURB(fd fd_usbfs, cmd const[USBDEVFS_SUBMITURB], arg ptr[in, usbdevfs_urb]) 37 38 # TODO: arg is a pointer to a previously submitted URB. 39 ioctl$USBDEVFS_DISCARDURB(fd fd_usbfs, cmd const[USBDEVFS_DISCARDURB], arg ptr[in, int64]) 40 41 ioctl$USBDEVFS_DISCSIGNAL(fd fd_usbfs, cmd const[USBDEVFS_DISCSIGNAL], arg ptr[in, usbdevfs_disconnectsignal]) 42 ioctl$USBDEVFS_CLAIMINTERFACE(fd fd_usbfs, cmd const[USBDEVFS_CLAIMINTERFACE], arg ptr[in, int32]) 43 ioctl$USBDEVFS_RELEASEINTERFACE(fd fd_usbfs, cmd const[USBDEVFS_RELEASEINTERFACE], arg ptr[in, int32]) 44 ioctl$USBDEVFS_IOCTL(fd fd_usbfs, cmd const[USBDEVFS_IOCTL], arg ptr[in, usbdevfs_ioctl]) 45 ioctl$USBDEVFS_CLAIM_PORT(fd fd_usbfs, cmd const[USBDEVFS_CLAIM_PORT], arg ptr[in, int32]) 46 ioctl$USBDEVFS_RELEASE_PORT(fd fd_usbfs, cmd const[USBDEVFS_RELEASE_PORT], arg ptr[in, int32]) 47 ioctl$USBDEVFS_GET_CAPABILITIES(fd fd_usbfs, cmd const[USBDEVFS_GET_CAPABILITIES], arg ptr[out, int32]) 48 ioctl$USBDEVFS_DISCONNECT_CLAIM(fd fd_usbfs, cmd const[USBDEVFS_DISCONNECT_CLAIM], arg ptr[in, usbdevfs_disconnect_claim]) 49 ioctl$USBDEVFS_ALLOC_STREAMS(fd fd_usbfs, cmd const[USBDEVFS_ALLOC_STREAMS], arg ptr[in, usbdevfs_streams]) 50 ioctl$USBDEVFS_FREE_STREAMS(fd fd_usbfs, cmd const[USBDEVFS_FREE_STREAMS], arg ptr[in, usbdevfs_streams]) 51 ioctl$USBDEVFS_DROP_PRIVILEGES(fd fd_usbfs, cmd const[USBDEVFS_DROP_PRIVILEGES], arg ptr[in, int32]) 52 ioctl$USBDEVFS_GET_SPEED(fd fd_usbfs, cmd const[USBDEVFS_GET_SPEED]) 53 ioctl$USBDEVFS_FORBID_SUSPEND(fd fd_usbfs, cmd const[USBDEVFS_FORBID_SUSPEND]) 54 ioctl$USBDEVFS_ALLOW_SUSPEND(fd fd_usbfs, cmd const[USBDEVFS_ALLOW_SUSPEND]) 55 ioctl$USBDEVFS_WAIT_FOR_RESUME(fd fd_usbfs, cmd const[USBDEVFS_WAIT_FOR_RESUME]) 56 57 usbdevfs_ep { 58 num int8:7[0:15] 59 dir int8:1 60 } 61 62 usbdevfs_ctrltransfer { 63 bRequestType flags[usb_request_type_flags, int8] 64 bRequest flags[usb_requests, int8] 65 wValue int16 66 wIndex int16 67 wLength len[data, int16] 68 timeout int32 69 data ptr[inout, array[int8]] 70 } 71 72 usb_request_type_flags = USB_DIR_OUT, USB_DIR_IN, USB_TYPE_MASK, USB_TYPE_STANDARD, USB_TYPE_CLASS, USB_TYPE_VENDOR, USB_TYPE_RESERVED, USB_RECIP_MASK, USB_RECIP_DEVICE, USB_RECIP_INTERFACE, USB_RECIP_ENDPOINT, USB_RECIP_OTHER, USB_RECIP_PORT, USB_RECIP_RPIPE 73 74 usbdevfs_bulktransfer { 75 ep align32[usbdevfs_ep] 76 len len[data, int32] 77 timeout int32 78 data ptr[inout, array[int8]] 79 } 80 81 usbdevfs_getdriver { 82 interface int32 83 driver array[int8, MAXDRIVERNAME] 84 } 85 86 usbdevfs_connectinfo { 87 devnum int32 88 slow int8 89 } 90 91 usbdevfs_setinterface { 92 interface int32 93 altsetting int32 94 } 95 96 usbdevfs_urb [ 97 urb_type_control usbdevfs_urb_control 98 urb_type_bulk usbdevfs_urb_bulk 99 urb_type_interrupt usbdevfs_urb_interrupt 100 urb_type_iso usbdevfs_urb_iso 101 ] [varlen] 102 103 usbdevfs_urb_control { 104 type const[USBDEVFS_URB_TYPE_CONTROL, int8] 105 endpoint usbdevfs_ep 106 status int32 107 flags flags[urb_flags, int32] 108 buffer ptr[in, usb_ctrlrequest] 109 buffer_length len[buffer, int32] 110 actual_length int32 111 start_frame int32 112 u const[0, int32] 113 error_count int32 114 signr int32 115 usercontext ptr[in, array[int8]] 116 } 117 118 usb_ctrlrequest { 119 bRequestType flags[usb_request_type_flags, int8] 120 bRequest flags[usb_requests, int8] 121 wValue int16 122 wIndex int16 123 wLength int16 124 } [packed] 125 126 usbdevfs_urb_bulk { 127 type const[USBDEVFS_URB_TYPE_BULK, int8] 128 endpoint usbdevfs_ep 129 status int32 130 flags flags[urb_flags, int32] 131 buffer ptr[in, array[int8]] 132 buffer_length len[buffer, int32] 133 actual_length int32 134 start_frame int32 135 stream_id int32 136 error_count int32 137 signr int32 138 usercontext ptr[in, array[int8]] 139 } 140 141 usbdevfs_urb_interrupt { 142 type const[USBDEVFS_URB_TYPE_INTERRUPT, int8] 143 endpoint usbdevfs_ep 144 status int32 145 flags flags[urb_flags, int32] 146 buffer ptr[in, array[int8]] 147 buffer_length len[buffer, int32] 148 actual_length int32 149 start_frame int32 150 u const[0, int32] 151 error_count int32 152 signr int32 153 usercontext ptr[in, array[int8]] 154 } 155 156 usbdevfs_urb_iso { 157 type const[USBDEVFS_URB_TYPE_ISO, int8] 158 endpoint usbdevfs_ep 159 status int32 160 flags flags[urb_flags, int32] 161 buffer ptr[in, array[int8]] 162 buffer_length len[buffer, int32] 163 actual_length int32 164 start_frame int32 165 number_of_packets len[iso_frame_desc, int32] 166 error_count int32 167 signr int32 168 usercontext ptr[in, array[int8]] 169 iso_frame_desc array[usbdevfs_iso_packet_desc, 1:127] 170 } 171 172 urb_flags = USBDEVFS_URB_SHORT_NOT_OK, USBDEVFS_URB_ISO_ASAP, USBDEVFS_URB_BULK_CONTINUATION, USBDEVFS_URB_NO_FSBR, USBDEVFS_URB_ZERO_PACKET, USBDEVFS_URB_NO_INTERRUPT 173 174 usbdevfs_iso_packet_desc { 175 length int32 176 actual_length int32 177 status int32 178 } 179 180 usbdevfs_disconnectsignal { 181 signr int32 182 context ptr[in, array[int8]] 183 } 184 185 usbdevfs_ioctl [ 186 usbdevfs_disconnect usbdevfs_ioctl_disconnect 187 usbdevfs_connect usbdevfs_ioctl_connect 188 usbdevfs_driver usbdevfs_ioctl_driver 189 ] 190 191 usbdevfs_ioctl_disconnect { 192 ifno int32 193 ioctl_code const[USBDEVFS_DISCONNECT, int32] 194 data const[0, intptr] 195 } 196 197 usbdevfs_ioctl_connect { 198 ifno int32 199 ioctl_code const[USBDEVFS_CONNECT, int32] 200 data const[0, intptr] 201 } 202 203 usbdevfs_ioctl_driver { 204 ifno int32 205 ioctl_code int32 206 data ptr[inout, array[int8]] 207 } 208 209 usbdevfs_disconnect_claim { 210 interface int32 211 flags flags[disconnect_flags, int32] 212 driver array[int8, MAXDRIVERNAME] 213 } 214 215 disconnect_flags = USBDEVFS_DISCONNECT_CLAIM_IF_DRIVER, USBDEVFS_DISCONNECT_CLAIM_EXCEPT_DRIVER 216 217 usbdevfs_streams { 218 num_streams int32[2:65536] 219 num_eps len[eps, int32] 220 eps array[usbdevfs_ep, 1:USB_MAXENDPOINTS] 221 }