aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource
diff options
context:
space:
mode:
authorNazime Hande Harputluoglu <handeharputlu@google.com>2020-10-01 21:53:57 +0000
committerAndrey Konovalov <andreyknvl@gmail.com>2020-10-02 22:00:33 +0200
commit5910646c6c6fbb5e48801342677bff9c4609a2ea (patch)
treeb6f4779d08ce53f9c7e046054ad7c2c78890a652 /pkg/csource
parent4969d6ca0dd952b9193c3546571a4e19a3b86718 (diff)
sys/linux: descriptions for USB/IP
Diffstat (limited to 'pkg/csource')
-rw-r--r--pkg/csource/generated.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go
index cdef36c54..83c3616a6 100644
--- a/pkg/csource/generated.go
+++ b/pkg/csource/generated.go
@@ -3875,6 +3875,50 @@ static long syz_io_uring_submit(volatile long a0, volatile long a1, volatile lon
#endif
+#if SYZ_EXECUTOR || __NR_syz_usbip_server_init
+
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/usb/ch9.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <unistd.h>
+#define VHCI_HC_PORTS 8
+#define VHCI_PORTS (VHCI_HC_PORTS * 2)
+
+static long syz_usbip_server_init(volatile long a0)
+{
+ int socket_pair[2];
+ char buffer[100];
+ static int port_alloc[2];
+
+ int speed = (int)a0;
+ bool usb3 = (speed == USB_SPEED_SUPER);
+
+ int rc = socketpair(AF_UNIX, SOCK_STREAM, 0, socket_pair);
+ if (rc < 0)
+ fail("syz_usbip_server_init : socketpair failed: %d", rc);
+
+ int client_fd = socket_pair[0];
+ int server_fd = socket_pair[1];
+
+ int available_port_num = __atomic_fetch_add(&port_alloc[usb3], 1, __ATOMIC_RELAXED);
+ if (available_port_num > VHCI_HC_PORTS) {
+ debug("syz_usbip_server_init : no more available port for : %d\n", available_port_num);
+ return -1;
+ }
+ int port_num = procid * VHCI_PORTS + usb3 * VHCI_HC_PORTS + available_port_num;
+ sprintf(buffer, "%d %d %s %d", port_num, client_fd, "0", speed);
+
+ write_file("/sys/devices/platform/vhci_hcd.0/attach", buffer);
+ return server_fd;
+}
+
+#endif
+
#if SYZ_EXECUTOR || __NR_syz_btf_id_by_name
#include <errno.h>