aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2019-11-14 15:43:37 +0100
committerAndrey Konovalov <andreyknvl@gmail.com>2019-11-15 14:53:30 +0100
commit90f3b019e42736360b0f1fcfcda486086b07c9a1 (patch)
tree9272a692ef3296242a3671ce9e5c3a9835d3e373
parentbe7a4ab6d8218c838164c65b32b1eae9b6d47517 (diff)
executor, pkg/host: update usb raw-gadget interface
The patches are being upstreamed and the interface has changed.
-rw-r--r--executor/common_usb.h36
-rw-r--r--pkg/csource/generated.go36
-rw-r--r--pkg/host/host_linux.go2
-rw-r--r--tools/syz-usbgen/keyboard.c32
4 files changed, 53 insertions, 53 deletions
diff --git a/executor/common_usb.h b/executor/common_usb.h
index 638e8bb85..061848738 100644
--- a/executor/common_usb.h
+++ b/executor/common_usb.h
@@ -74,6 +74,12 @@ static bool parse_usb_descriptor(char* buffer, size_t length, struct usb_device_
return true;
}
+struct usb_raw_init {
+ __u64 speed;
+ const __u8* driver_name;
+ const __u8* device_name;
+};
+
enum usb_raw_event_type {
USB_RAW_EVENT_INVALID,
USB_RAW_EVENT_CONNECT,
@@ -81,22 +87,16 @@ enum usb_raw_event_type {
};
struct usb_raw_event {
- uint32 type;
- uint32 length;
- char data[0];
-};
-
-struct usb_raw_init {
- uint64 speed;
- const char* driver_name;
- const char* device_name;
+ __u32 type;
+ __u32 length;
+ __u8 data[0];
};
struct usb_raw_ep_io {
- uint16 ep;
- uint16 flags;
- uint32 length;
- char data[0];
+ __u16 ep;
+ __u16 flags;
+ __u32 length;
+ __u8 data[0];
};
#define USB_RAW_IOCTL_INIT _IOW('U', 0, struct usb_raw_init)
@@ -105,23 +105,23 @@ struct usb_raw_ep_io {
#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, int)
+#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, uint32)
+#define USB_RAW_IOCTL_VBUS_DRAW _IOW('U', 10, __u32)
static int usb_raw_open()
{
- return open("/sys/kernel/debug/usb/raw-gadget", O_RDWR);
+ return open("/dev/raw-gadget", O_RDWR);
}
static int usb_raw_init(int fd, uint32 speed, const char* driver, const char* device)
{
struct usb_raw_init arg;
arg.speed = speed;
- arg.driver_name = driver;
- arg.device_name = device;
+ arg.driver_name = (const __u8*)driver;
+ arg.device_name = (const __u8*)device;
return ioctl(fd, USB_RAW_IOCTL_INIT, &arg);
}
diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go
index 4bac21f5d..86c03f8d2 100644
--- a/pkg/csource/generated.go
+++ b/pkg/csource/generated.go
@@ -2066,6 +2066,12 @@ static bool parse_usb_descriptor(char* buffer, size_t length, struct usb_device_
return true;
}
+struct usb_raw_init {
+ __u64 speed;
+ const __u8* driver_name;
+ const __u8* device_name;
+};
+
enum usb_raw_event_type {
USB_RAW_EVENT_INVALID,
USB_RAW_EVENT_CONNECT,
@@ -2073,22 +2079,16 @@ enum usb_raw_event_type {
};
struct usb_raw_event {
- uint32 type;
- uint32 length;
- char data[0];
-};
-
-struct usb_raw_init {
- uint64 speed;
- const char* driver_name;
- const char* device_name;
+ __u32 type;
+ __u32 length;
+ __u8 data[0];
};
struct usb_raw_ep_io {
- uint16 ep;
- uint16 flags;
- uint32 length;
- char data[0];
+ __u16 ep;
+ __u16 flags;
+ __u32 length;
+ __u8 data[0];
};
#define USB_RAW_IOCTL_INIT _IOW('U', 0, struct usb_raw_init)
@@ -2097,23 +2097,23 @@ struct usb_raw_ep_io {
#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, int)
+#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, uint32)
+#define USB_RAW_IOCTL_VBUS_DRAW _IOW('U', 10, __u32)
static int usb_raw_open()
{
- return open("/sys/kernel/debug/usb/raw-gadget", O_RDWR);
+ return open("/dev/raw-gadget", O_RDWR);
}
static int usb_raw_init(int fd, uint32 speed, const char* driver, const char* device)
{
struct usb_raw_init arg;
arg.speed = speed;
- arg.driver_name = driver;
- arg.device_name = device;
+ arg.driver_name = (const __u8*)driver;
+ arg.device_name = (const __u8*)device;
return ioctl(fd, USB_RAW_IOCTL_INIT, &arg);
}
diff --git a/pkg/host/host_linux.go b/pkg/host/host_linux.go
index c071a8cb9..d9a8c24f9 100644
--- a/pkg/host/host_linux.go
+++ b/pkg/host/host_linux.go
@@ -546,7 +546,7 @@ func checkNetworkInjection() string {
}
func checkUSBInjection() string {
- if err := osutil.IsAccessible("/sys/kernel/debug/usb/raw-gadget"); err != nil {
+ if err := osutil.IsAccessible("/dev/raw-gadget"); err != nil {
return err.Error()
}
return ""
diff --git a/tools/syz-usbgen/keyboard.c b/tools/syz-usbgen/keyboard.c
index 819d0eff8..9efa53c2e 100644
--- a/tools/syz-usbgen/keyboard.c
+++ b/tools/syz-usbgen/keyboard.c
@@ -42,6 +42,12 @@ struct hid_descriptor {
/*----------------------------------------------------------------------*/
+struct usb_raw_init {
+ __u64 speed;
+ const __u8 *driver_name;
+ const __u8 *device_name;
+};
+
enum usb_raw_event_type {
USB_RAW_EVENT_INVALID,
USB_RAW_EVENT_CONNECT,
@@ -49,22 +55,16 @@ enum usb_raw_event_type {
};
struct usb_raw_event {
- uint32_t type;
- uint32_t length;
- char data[0];
-};
-
-struct usb_raw_init {
- uint64_t speed;
- const char *driver_name;
- const char *device_name;
+ __u32 type;
+ __u32 length;
+ __u8 data[0];
};
struct usb_raw_ep_io {
- uint16_t ep;
- uint16_t flags;
- uint32_t length;
- char data[0];
+ __u16 ep;
+ __u16 flags;
+ __u32 length;
+ __u8 data[0];
};
#define USB_RAW_IOCTL_INIT _IOW('U', 0, struct usb_raw_init)
@@ -73,16 +73,16 @@ struct usb_raw_ep_io {
#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, int)
+#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, uint32_t)
+#define USB_RAW_IOCTL_VBUS_DRAW _IOW('U', 10, __u32)
/*----------------------------------------------------------------------*/
int usb_raw_open() {
- int fd = open("/sys/kernel/debug/usb/raw-gadget", O_RDWR);
+ int fd = open("/dev/raw-gadget", O_RDWR);
if (fd < 0) {
perror("open()");
exit(EXIT_FAILURE);