aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/usbip
AgeCommit message (Collapse)Author
2017-07-12usb: usbip: set buffer pointers to NULL after freeMichael Grzeschik
commit b3b51417d0af63fb9a06662dc292200aed9ea53f upstream. The usbip stack dynamically allocates the transfer_buffer and setup_packet of each urb that got generated by the tcp to usb stub code. As these pointers are always used only once we will set them to NULL after use. This is done likewise to the free_urb code in vudc_dev.c. This patch fixes double kfree situations where the usbip remote side added the URB_FREE_BUFFER. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Acked-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-05-17USB: usbip: fix nonconforming hub descriptorJohan Hovold
Fix up the root-hub descriptor to accommodate the variable-length DeviceRemovable and PortPwrCtrlMask fields, while marking all ports as removable (and leaving the reserved bit zero unset). Also add a build-time constraint on VHCI_HC_PORTS which must never be greater than USB_MAXCHILDREN (but this was only enforced through a KConfig constant). This specifically fixes the descriptor layout whenever VHCI_HC_PORTS is greater than seven (default is 8). Fixes: 04679b3489e0 ("Staging: USB/IP: add client driver") Cc: Takahiro Hirofuchi <hirofuchi@users.sourceforge.net> Cc: Valentina Manea <valentina.manea.m@gmail.com> Signed-off-by: Johan Hovold <johan@kernel.org> Acked-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-08usb: usbip: Remove unnecessary get_vdev()Yuyang Du
vhci_tx_urb() should be able to get the vhci_device from its caller vhci_urb_enqueue(), instead of brutal-force searching it. Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Yuyang Du <yuyang.du@intel.com> Acked-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-03Merge branch 'WIP.sched-core-for-linus' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip Pull sched.h split-up from Ingo Molnar: "The point of these changes is to significantly reduce the <linux/sched.h> header footprint, to speed up the kernel build and to have a cleaner header structure. After these changes the new <linux/sched.h>'s typical preprocessed size goes down from a previous ~0.68 MB (~22K lines) to ~0.45 MB (~15K lines), which is around 40% faster to build on typical configs. Not much changed from the last version (-v2) posted three weeks ago: I eliminated quirks, backmerged fixes plus I rebased it to an upstream SHA1 from yesterday that includes most changes queued up in -next plus all sched.h changes that were pending from Andrew. I've re-tested the series both on x86 and on cross-arch defconfigs, and did a bisectability test at a number of random points. I tried to test as many build configurations as possible, but some build breakage is probably still left - but it should be mostly limited to architectures that have no cross-compiler binaries available on kernel.org, and non-default configurations" * 'WIP.sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (146 commits) sched/headers: Clean up <linux/sched.h> sched/headers: Remove #ifdefs from <linux/sched.h> sched/headers: Remove the <linux/topology.h> include from <linux/sched.h> sched/headers, hrtimer: Remove the <linux/wait.h> include from <linux/hrtimer.h> sched/headers, x86/apic: Remove the <linux/pm.h> header inclusion from <asm/apic.h> sched/headers, timers: Remove the <linux/sysctl.h> include from <linux/timer.h> sched/headers: Remove <linux/magic.h> from <linux/sched/task_stack.h> sched/headers: Remove <linux/sched.h> from <linux/sched/init.h> sched/core: Remove unused prefetch_stack() sched/headers: Remove <linux/rculist.h> from <linux/sched.h> sched/headers: Remove the 'init_pid_ns' prototype from <linux/sched.h> sched/headers: Remove <linux/signal.h> from <linux/sched.h> sched/headers: Remove <linux/rwsem.h> from <linux/sched.h> sched/headers: Remove the runqueue_is_locked() prototype sched/headers: Remove <linux/sched.h> from <linux/sched/hotplug.h> sched/headers: Remove <linux/sched.h> from <linux/sched/debug.h> sched/headers: Remove <linux/sched.h> from <linux/sched/nohz.h> sched/headers: Remove <linux/sched.h> from <linux/sched/stat.h> sched/headers: Remove the <linux/gfp.h> include from <linux/sched.h> sched/headers: Remove <linux/rtmutex.h> from <linux/sched.h> ...
2017-03-02Merge branch 'work.sendmsg' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs Pull vfs sendmsg updates from Al Viro: "More sendmsg work. This is a fairly separate isolated stuff (there's a continuation around lustre, but that one was too late to soak in -next), thus the separate pull request" * 'work.sendmsg' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: ncpfs: switch to sock_sendmsg() ncpfs: don't mess with manually advancing iovec on send ncpfs: sendmsg does *not* bugger iovec these days ceph_tcp_sendpage(): use ITER_BVEC sendmsg afs_send_pages(): use ITER_BVEC rds: remove dead code ceph: switch to sock_recvmsg() usbip_recv(): switch to sock_recvmsg() iscsi_target: deal with short writes on the tx side [nbd] pass iov_iter to nbd_xmit() [nbd] switch sock_xmit() to sock_{send,recv}msg() [drbd] use sock_sendmsg()
2017-03-02sched/headers: Prepare to move the get_task_struct()/put_task_struct() and ↵Ingo Molnar
related APIs from <linux/sched.h> to <linux/sched/task.h> But first update usage sites with the new header dependency. Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-02-27scripts/spelling.txt: add "overwritting" pattern and fix typo instancesMasahiro Yamada
Fix typos and add the following to the scripts/spelling.txt: overwritting||overwriting Link: http://lkml.kernel.org/r/1481573103-11329-29-git-send-email-yamada.masahiro@socionext.com Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-09drivers: usb: usbip: Add missing break statement to switchGustavo A. R. Silva
Add missing break statement to prevent the code for case USB_PORT_FEAT_C_RESET falling through to the default case. Addresses-Coverity-ID: 143155 Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-12-26usbip_recv(): switch to sock_recvmsg()Al Viro
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2016-12-06usbip: fix warning in vhci_hcd_probe/lockdep_init_mapShuah Khan
vhci_hcd calls sysfs_create_group() with dynamically allocated sysfs attributes triggering the lock-class key not persistent warning. Call sysfs_attr_init() for dynamically allocated sysfs attributes to fix it. vhci_hcd vhci_hcd: USB/IP Virtual Host Controller vhci_hcd vhci_hcd: new USB bus registered, assigned bus number 2 BUG: key ffff88006a7e8d18 not in .data! ------------[ cut here ]------------ WARNING: CPU: 0 PID: 1 at kernel/locking/lockdep.c:3131 lockdep_init_map+0x60c/0x770 DEBUG_LOCKS_WARN_ON(1)[ 1.567044] Modules linked in: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.9.0-rc7+ #58 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 ffff88006bce6eb8 ffffffff81f96c8a ffffffff00000a02 1ffff1000d79cd6a ffffed000d79cd62 000000046bce6ed8 0000000041b58ab3 ffffffff8598af40 ffffffff81f969f8 0000000000000000 0000000041b58ab3 0000000000000200 Call Trace: [< inline >] __dump_stack lib/dump_stack.c:15 [<ffffffff81f96c8a>] dump_stack+0x292/0x398 lib/dump_stack.c:51 [<ffffffff812b808f>] __warn+0x19f/0x1e0 kernel/panic.c:550 [<ffffffff812b8195>] warn_slowpath_fmt+0xc5/0x110 kernel/panic.c:565 [<ffffffff813f3efc>] lockdep_init_map+0x60c/0x770 kernel/locking/lockdep.c:3131 [<ffffffff819e43d4>] __kernfs_create_file+0x114/0x2a0 fs/kernfs/file.c:954 [<ffffffff819e68f5>] sysfs_add_file_mode_ns+0x225/0x520 fs/sysfs/file.c:305 [< inline >] create_files fs/sysfs/group.c:64 [<ffffffff819e8a89>] internal_create_group+0x239/0x8f0 fs/sysfs/group.c:134 [<ffffffff819e915f>] sysfs_create_group+0x1f/0x30 fs/sysfs/group.c:156 [<ffffffff8323de24>] vhci_start+0x5b4/0x7a0 drivers/usb/usbip/vhci_hcd.c:978 [<ffffffff82c907ca>] usb_add_hcd+0x8da/0x1c60 drivers/usb/core/hcd.c:2867 [<ffffffff8323bc57>] vhci_hcd_probe+0x97/0x130 drivers/usb/usbip/vhci_hcd.c:1103 --- --- ---[ end trace c33c7b202cf3aac8 ]--- Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Reported-by: Andrey Konovalov <andreyknvl@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-12-05usbip: vudc: Refactor init_vudc_hw() to be more obviousKrzysztof Opasiak
Current implementation of init_vudc_hw() adds ep0 to ep_list and then after looping through all endpoints removes it from that list. As this may be misleading let's refactor this function and avoid adding and removing ep0 to eplist and place it immediately in correct place. In addition let's remove redundant 0 assignments as ep array is zeroed during allocation. Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com> Acked-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-12-05usbip: vudc: fix: Clear already_seen flag also for ep0Krzysztof Opasiak
ep_list inside gadget structure doesn't contain ep0. It is stored separately in ep0 field. This causes an urb hang if gadget driver decides to delay setup handling. On host side this is visible as timeout error when setting configuration. This bug can be reproduced using for example any gadget with mass storage function. Fixes: abdb29574322 ("usbip: vudc: Add vudc_transfer") Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com> Cc: stable <stable@vger.kernel.org> Acked-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-18Merge tag 'usb-for-v4.10' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next Felipe writes: usb: patches for v4.10 merge window One big merge this time with a total of 166 non-merge commits. Most of the work, by far, is on dwc2 this time (68.2%) with dwc3 a far second (22.5%). The remaining 9.3% are scattered on gadget drivers. The most important changes for dwc2 are the peripheral side DMA support implemented by Synopsys folks and support for the new IOT dwc2 compatible core from Synopsys. In dwc3 land we have support for high-bandwidth, high-speed isochronous endpoints and some non-critical fixes for large scatter lists. Apart from these, we have our usual set of cleanups, non-critical fixes, etc.
2016-11-07usbip: fix possibility of dereference by NULLL pointer in vhci_hcd.cNobuo Iwata
This patch fixes possibility of dereference by NULLL pointer in "[PATCH v5 1/3] usbip: vhci extension: modifications to vhci driver" which has been merged to 4.9-rc1. It occurs when a URB with pointer to invalid USB/IP device is enqueued in race condition against detach operation. A pointer was passed to vdev_to_vhci() before NULL check. In vdev_to_vhci(), there's a dereference by the pointer. This patch moves vdev_to_vhci() after NULL check of the pointer. Signed-off-by: Nobuo Iwata <nobuo.iwata@fujixerox.co.jp> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-03usb: ip: remove unnecessary & operationFelipe Balbi
Now that usb_endpoint_maxp() only returns the lowest 11 bits from wMaxPacketSize, we can remove the & operation from this driver. Cc: Valentina Manea <valentina.manea.m@gmail.com> Cc: Shuah Khan <shuah@kernel.org> Cc: <linux-usb@vger.kernel.org> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2016-10-27usb: usbip:checkpatch; fix bare use of unsignedJai Krishna
This patch fixes the following checkpatch warning for usbip files WARNING: Prefer 'unsigned int' to bare use of 'unsigned' Signed-off-by: Jai Krishna <rjk1024@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-27usb: Kconfig: using select for USB_COMMON dependencyPeter Chen
According to (badf6d47f8a9 "usb: common: rework CONFIG_USB_COMMON logic") we should select USB_COMMON at Kconfig when usb common stuffs are needed, but some of Kconfig enties have not followed it, update them. Cc: Felipe Balbi <balbi@kernel.org> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Peter Chen <peter.chen@nxp.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-30usb: usbip: vudc: fix left shift overflowNicolas Iooss
In v_recv_cmd_submit(), urb_p->urb->pipe has the type unsigned int (which is 32-bit long on x86_64) but 11<<30 results in a 34-bit integer. Therefore the 2 leading bits are truncated and urb_p->urb->pipe &= ~(11 << 30); has the same meaning as urb_p->urb->pipe &= ~(3 << 30); This second statement seems to be how the code was intended to be written, as PIPE_ constants have values between 0 and 3. The overflow has been detected with a clang warning: drivers/usb/usbip/vudc_rx.c:145:27: warning: signed shift result (0x2C0000000) requires 35 bits to represent, but 'int' only has 32 bits [-Wshift-overflow] urb_p->urb->pipe &= ~(11 << 30); ~~ ^ ~~ Fixes: 79c02cb1fd5c ("usbip: vudc: Add vudc_rx") Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-30usbip: vudc: Fix apparent cut-n-paste errorDave Jones
Coverity picked up that this looks like a cut-n-paste from an almost identical sequence below that didn't get its variable renamed. Signed-off-by: Dave Jones <davej@codemonkey.org.uk> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-15usbip: vhci_hcd: fix return value check in add_platform_device()Wei Yongjun
In case of error, the function platform_device_register_simple() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-15usb: usbip: stub_rx: don't print error when allocating urb failsWolfram Sang
kmalloc will print enough information in case of failure. Signed-off-by: Wolfram Sang <wsa-dev@sang-engineering.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-09usbip: vhci extension: modifications to vhci driverNobuo Iwata
Modification to Kconfig, vhci_hc.c, vhci.h and vhci_sysfs.c. 1. kernel config Followings are added. USBIP_VHCI_HC_PORTS: Number of ports per USB/IP virtual host controller. The default is 8 - same as current VHCI_NPORTS. USBIP_VHCI_NR_HCS: Number of USB/IP virtual host controllers. The default is 1. This paratmeter is replaced with USBIP_VHCI_INIT_HCS and USBIP_VHCI_MAX_HCS included in succeeding dynamic extension patch. 2. the_controller to controllers the_controller is changed to vhci_pdevs: array of struct platform_device. 3. vhci_sysfs.c Sysfs structure is changed as following. BEFORE: /sys/devices/platform +-- vhci +-- status +-- attach +-- detach +-- usbip_debug AFTER: example for CONFIG_USBIP_NR_HCS=4 /sys/devices/platform +-- vhci | +-- nports | +-- status | +-- status.1 | +-- status.2 | +-- status.3 | +-- attach | +-- detach | +-- usbip_debug +-- vhci.1 +-- vhci.2 +-- vhci.3 vhci[.N] is shown for each host controller kobj. vhch.1, vhci.2, ... are shown only when CONFIG_USBIP_NR_HCS is more than 1. Only 'vhci' (without number) has user space interfaces. 'nports' is newly added to give ports-per-controller and number of controlles. Before that, number of ports is acquired by reading status lines. Status is divided for each controller to avoid page size (4KB) limitation. Old userspace tool binaries work with the first status within the first controller. Inconsistency between status header and content is fixed. 4th and 5th column are header: "dev bus" content(unused): "000 000" content(used): "%08x", devid Only 1st and 2nd column are used by program. In old version, sscanf() in parse_status expect no bus column. And bus_id string is shown in the last column. Then bus in the header is removed and unused content is replaced with 8 zeros. The sscanf() expects more than 5 columns and new has 6 columns so there's no compatibility issue in this change. Signed-off-by: Nobuo Iwata <nobuo.iwata@fujixerox.co.jp> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-20Merge 4.7-rc4 into usb-nextGreg Kroah-Hartman
We need the 4.7-rc4 fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-17usbip: rate limit get_frame_number messageGreg Kroah-Hartman
It's annoying to constantly see the same "Not yet implemented" message over and over with nothing able to be done about it, so rate limit it for now to keep user's logs "clean". Reported-by: Lars Täuber <lars.taeuber@web.de> Tested-by: Lars Täuber <lars.taeuber@web.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-07usb: usbip: remove null checkSudip Mukherjee
The only caller of get_gadget_descs() has already dereferenced udc before calling this function, so udc can not be NULL at this point of the code and hence no use of checking it. Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-07usbip: don't call stub_device_reset() during stub_disconnect()Alexander Popov
stub_disconnect() calls stub_device_reset() during usb_unbind_device() when usb device is locked. So usb_lock_device_for_reset() in stub_device_reset() in that case polls for one second and returns -EBUSY anyway. Remove useless flag USBIP_EH_RESET from SDEV_EVENT_REMOVED. Signed-off-by: Alexander Popov <alpopov@ptsecurity.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-29usb: usbip: Avoid NULL pointer dereference in case of errorKrzysztof Opasiak
One line above we have checked that udc is NULL so we shouldn't dereference it while printing error message. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-29usbip: vudc: make dev_desc attribute binaryIgor Kotrasinski
We read a struct usb_device_descriptor from it, so make it an actual binary attribute. Signed-off-by: Igor Kotrasinski <i.kotrasinsk@gmail.com> Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com> Tested-by: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-28usbip: vudc: fix Kconfig dependenciesArnd Bergmann
With the addition of VUDC, the USBIP stack can now be used on configurations without USB host support, but trying to build it with USB gadget support disabled fails with drivers/usb/built-in.o: In function `vep_dequeue': vudc_main.c:(.text+0xa6ddc): undefined reference to `usb_gadget_giveback_request' drivers/usb/built-in.o: In function `nuke': vudc_main.c:(.text+0xa6ea8): undefined reference to `usb_gadget_giveback_request' drivers/usb/built-in.o: In function `vudc_device_reset': vudc_main.c:(.text+0xa720c): undefined reference to `usb_gadget_udc_reset' drivers/usb/built-in.o: In function `vudc_probe': This addresses both issues, by changing the dependency for USBIP_CORE to USB_COMMON, and adding additional dependencies on USB or USB_GADGET for the individual portions as needed. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Fixes: 9360575c5837 ("usbip: vudc: Add vudc to Kconfig") Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-28usbip: safe completion against unbind operationNobuo Iwata
This patch adds a code fragment to ignore completing URBs in closing connection. Regarding this patch, 2 execution contexts are related. 1) stub_tx.c: stub_complete() which is called from USB core 1-1) add to unlink list and free URB or 1-2) move to tx list 2) stub_dev.c: stub_shutdown_connection() which is invoked by unbind operation through sysfs. 2-1) stop TX/RX threads 2-2) close TCP connection and set ud.tcp_socket to NULL 2-3) cleanup pending URBs by stub_device_cleanup_urbs(sdev) 2-4) free unlink list (no lock) In the race condition, URBs which will be cleared in 2-3) may be handled in 1). In case 1-1), it will not be transferred bcause tx threads are stooped in 2-1). In case 1-2), may be freed in 2-4). With this patch, after 2-2), completing URBs in 1) will not be handled and cleared in 2-3). The kernel log with this patch is as below. kernel: usbip_core: usbip_kernel_unlink:792: shutting down tcp_socket ef61d980 kernel: usbip-host 1-3: free sdev f5df6180 kernel: usbip-host 1-3: free urb f5df6700 kernel: usbip-host 1-3: Enter kernel: usbip_core: usbip_stop_eh:132: usbip_eh waiting completion 5 kernel: usbip_host: stub_complete:71: complete! status 0 kernel: usbip_host: stub_complete:102: ignore urb for closed connection e725fc00 (*) kernel: usbip_host: stub_complete:71: complete! status -2 kernel: usbip-host 1-3: stopped by a call to usb_kill_urb() because of cleaning up a virtual connection kernel: usbip-host 1-3: free urb e725fc00 (**) kernel: usbip-host 1-3: free urb e725e000 kernel: usbip_host: stub_complete:71: complete! status -2 kernel: usbip-host 1-3: stopped by a call to usb_kill_urb() because of cleaning up a virtual connection kernel: usbip-host 1-3: free urb e725f800 kernel: usbip_host: stub_complete:71: complete! status -2 kernel: usbip-host 1-3: stopped by a call to usb_kill_urb() because of cleaning up a virtual connection kernel: usbip-host 1-3: free urb e725e800 kernel: usbip_host: stub_complete:71: complete! status -2 kernel: usbip-host 1-3: stopped by a call to usb_kill_urb() because of cleaning up a virtual connection kernel: usbip-host 1-3: device reset kernel: usbip-host 1-3: lock for reset kernel: usbip_host: store_match_busid:178: del busid 1-3 kernel: uvcvideo: Found UVC 1.00 device Venus USB2.0 Camera (056e:700a) kernel: input: Venus USB2.0 Camera as /devices/pci0000:00/0000:00:1a.7/usb1/1-3/1-3:1.0/input/input22 (*) skipped with this patch in completion (**) released in 2-3 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-28usb: usbip: vudc: Rename find_endpoint() to vudc_find_endpoint()Krzysztof Opasiak
As find_endpoint() is a global funcion rename it to vudc_find_endpoint() to clearly mark where does it come from. Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-28usbip: fix NULL pointer dereference on errorsAlexander Popov
Fix NULL pointer dereference and obsolete comments forgotten when usbip server was converted from an interface driver to a device driver. Signed-off-by: Alexander Popov <alpopov@ptsecurity.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-28usb: usbip: vudc: Fix WARN_ON() usage patternKrzysztof Opasiak
Fix WARN_ON() macro usage as suggested by Felipe. Instead of using: if (cond) { WARN_ON(1); do_stuff(); } Use a better pattern with WARN_ON() placed in if condition: if (WARN_ON(cond)) do_stuff(); Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-26usbip: vudc: Add vudc to KconfigIgor Kotrasinski
Add the driver to Kconfig to make it visible in menuconfig and allow people to compile it. This commit is a result of cooperation between Samsung R&D Institute Poland and Open Operating Systems Student Society at University of Warsaw (O2S3@UW) consisting of: Igor Kotrasinski <ikotrasinsk@gmail.com> Karol Kosik <karo9@interia.eu> Ewelina Kosmider <3w3lfin@gmail.com> Dawid Lazarczyk <lazarczyk.dawid@gmail.com> Piotr Szulc <ps347277@students.mimuw.edu.pl> Tutor and project owner: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Igor Kotrasinski <i.kotrasinsk@samsung.com> Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-26usbip: vudc: Add SysFS infrastructure for VUDCIgor Kotrasinski
Add sysfs attributes to allow controlling vudc from usbip tools. dev_desc - device descriptor of current gadget. This is required to be consisten with current usbip protocol and allow to list exportable devices on given machine. usbip_sockfd - allows to pass socket to kernel to start usbip transfer. usbip_status - currnent status of device This commit is a result of cooperation between Samsung R&D Institute Poland and Open Operating Systems Student Society at University of Warsaw (O2S3@UW) consisting of: Igor Kotrasinski <ikotrasinsk@gmail.com> Karol Kosik <karo9@interia.eu> Ewelina Kosmider <3w3lfin@gmail.com> Dawid Lazarczyk <lazarczyk.dawid@gmail.com> Piotr Szulc <ps347277@students.mimuw.edu.pl> Tutor and project owner: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Igor Kotrasinski <i.kotrasinsk@samsung.com> Signed-off-by: Karol Kosik <karo9@interia.eu> [Various bug fixes, improvements and commit msg update] Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-26usbip: vudc: Add UDC specific opsIgor Kotrasinski
Add endpoints definitions and ops for both endpoints and gadget. Add also a suitable platform driver and functions for handling usbip events. This commit is a result of cooperation between Samsung R&D Institute Poland and Open Operating Systems Student Society at University of Warsaw (O2S3@UW) consisting of: Igor Kotrasinski <ikotrasinsk@gmail.com> Karol Kosik <karo9@interia.eu> Ewelina Kosmider <3w3lfin@gmail.com> Dawid Lazarczyk <lazarczyk.dawid@gmail.com> Piotr Szulc <ps347277@students.mimuw.edu.pl> Tutor and project owner: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Igor Kotrasinski <i.kotrasinsk@samsung.com> Signed-off-by: Karol Kosik <karo9@interia.eu> [Various bug fixes, improvements and commit msg update] Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-26usbip: vudc: Add vudc_txIgor Kotrasinski
This file contains functions for returning requests to the client. It also has functions that add requests completed in vudc_rx and vudc_transfer to the return queue. This commit is a result of cooperation between Samsung R&D Institute Poland and Open Operating Systems Student Society at University of Warsaw (O2S3@UW) consisting of: Igor Kotrasinski <ikotrasinsk@gmail.com> Karol Kosik <karo9@interia.eu> Ewelina Kosmider <3w3lfin@gmail.com> Dawid Lazarczyk <lazarczyk.dawid@gmail.com> Piotr Szulc <ps347277@students.mimuw.edu.pl> Tutor and project owner: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Igor Kotrasinski <i.kotrasinsk@samsung.com> Signed-off-by: Karol Kosik <karo9@interia.eu> Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-26usbip: vudc: Add vudc_transferIgor Kotrasinski
This file contains a function that simulates USB traffic, based on the one in dummy_hcd. Is also handles udc-directed control requests, and contains functions for setting up and controlling a timer for the emulation. This commit is a result of cooperation between Samsung R&D Institute Poland and Open Operating Systems Student Society at University of Warsaw (O2S3@UW) consisting of: Igor Kotrasinski <ikotrasinsk@gmail.com> Karol Kosik <karo9@interia.eu> Ewelina Kosmider <3w3lfin@gmail.com> Dawid Lazarczyk <lazarczyk.dawid@gmail.com> Piotr Szulc <ps347277@students.mimuw.edu.pl> Tutor and project owner: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Igor Kotrasinski <i.kotrasinsk@samsung.com> Signed-off-by: Karol Kosik <karo9@interia.eu> Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-26usbip: vudc: Add vudc_rxIgor Kotrasinski
Add functions which allows to receive urbs from the client. It receives traffic in a loop in a separate thread. This commit is a result of cooperation between Samsung R&D Institute Poland and Open Operating Systems Student Society at University of Warsaw (O2S3@UW) consisting of: Igor Kotrasinski <ikotrasinsk@gmail.com> Karol Kosik <karo9@interia.eu> Ewelina Kosmider <3w3lfin@gmail.com> Dawid Lazarczyk <lazarczyk.dawid@gmail.com> Piotr Szulc <ps347277@students.mimuw.edu.pl> Tutor and project owner: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Igor Kotrasinski <i.kotrasinsk@samsung.com> Signed-off-by: Karol Kosik <karo9@interia.eu> Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-26usbip: vudc: Add VUDC main fileIgor Kotrasinski
Add main vudc module file. This allows us to register suitable platform device and driver (just like dummy_hcd does). Currently number of vudc instances is determined using module parameter but whole infrastructure is suitable to make vudc creation dynamic (for example via configfs). This commit is a result of cooperation between Samsung R&D Institute Poland and Open Operating Systems Student Society at University of Warsaw (O2S3@UW) consisting of: Igor Kotrasinski <ikotrasinsk@gmail.com> Karol Kosik <karo9@interia.eu> Ewelina Kosmider <3w3lfin@gmail.com> Dawid Lazarczyk <lazarczyk.dawid@gmail.com> Piotr Szulc <ps347277@students.mimuw.edu.pl> Tutor and project owner: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Igor Kotrasinski <i.kotrasinsk@samsung.com> Signed-off-by: Karol Kosik <karo9@interia.eu> [Various bug fixes and commit message update] Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-26usbip: vudc: Make usbip_common vudc-awareIgor Kotrasinski
Add constants for VUDC events in usbip_common.h and make use of them in usbip_common.c. This commit is a result of cooperation between Samsung R&D Institute Poland and Open Operating Systems Student Society at University of Warsaw (O2S3@UW) consisting of: Igor Kotrasinski <ikotrasinsk@gmail.com> Karol Kosik <karo9@interia.eu> Ewelina Kosmider <3w3lfin@gmail.com> Dawid Lazarczyk <lazarczyk.dawid@gmail.com> Piotr Szulc <ps347277@students.mimuw.edu.pl> Tutor and project owner: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Igor Kotrasinski <i.kotrasinsk@samsung.com> Signed-off-by: Karol Kosik <karo9@interia.eu> [Small fixes and commit message update] Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-26usbip: vudc: Add header for USB/IP UDCIgor Kotrasinski
Add header with definitions needed by vudc driver. This commit is a result of cooperation between Samsung R&D Institute Poland and Open Operating Systems Student Society at University of Warsaw (O2S3@UW) consisting of: Igor Kotrasinski <ikotrasinsk@gmail.com> Karol Kosik <karo9@interia.eu> Ewelina Kosmider <3w3lfin@gmail.com> Dawid Lazarczyk <lazarczyk.dawid@gmail.com> Piotr Szulc <ps347277@students.mimuw.edu.pl> Tutor and project owner: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Igor Kotrasinski <i.kotrasinsk@samsung.com> Signed-off-by: Karol Kosik <karo9@interia.eu> [Some small improvements] Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-19usbip: event handler as one threadNobuo Iwata
Dear all, 1. Overview In current USB/IP implementation, event kernel threads are created for each port. The functions of the threads are closing connection and error handling so they don't have not so many events to handle. There's no need to have thread for each port. BEFORE) vhci side - VHCI_NPORTS(8) threads are created. $ ps aux | grep usbip root 10059 0.0 0.0 0 0 ? S 17:06 0:00 [usbip_eh] root 10060 0.0 0.0 0 0 ? S 17:06 0:00 [usbip_eh] root 10061 0.0 0.0 0 0 ? S 17:06 0:00 [usbip_eh] root 10062 0.0 0.0 0 0 ? S 17:06 0:00 [usbip_eh] root 10063 0.0 0.0 0 0 ? S 17:06 0:00 [usbip_eh] root 10064 0.0 0.0 0 0 ? S 17:06 0:00 [usbip_eh] root 10065 0.0 0.0 0 0 ? S 17:06 0:00 [usbip_eh] root 10066 0.0 0.0 0 0 ? S 17:06 0:00 [usbip_eh] BEFORE) stub side - threads will be created every bind operation. $ ps aux | grep usbip root 8368 0.0 0.0 0 0 ? S 17:56 0:00 [usbip_eh] root 8399 0.0 0.0 0 0 ? S 17:56 0:00 [usbip_eh] This patch put event threads of stub and vhci driver as one workqueue. AFTER) only one event threads in each vhci and stub side. $ ps aux | grep usbip root 10457 0.0 0.0 0 0 ? S< 17:47 0:00 [usbip_event] 2. Modification to usbip_event.c BEFORE) kernel threads are created in usbip_start_eh(). AFTER) one workqueue is created in new usbip_init_eh(). Event handler which was main loop of kernel thread is modified to workqueue handler. Events themselves are stored in struct usbip_device - same as before. usbip_devices which have event are listed in event_list. The handler picks an element from the list and wakeup usbip_device. The wakeup method is same as before. usbip_in_eh() substitutes statement which checks whether functions are called from eh_ops or not. In this function, the worker context is used for the checking. The context will be set in a variable in the beginning of first event handling. usbip_in_eh() is used in event handler so it works well. 3. Modifications to programs using usbip_event.c Initialization and termination of workqueue are added to init and exit routine of usbip_core respectively. A. version info v2) # Merged 1/2 event handler itself and 2/2 user programs because of auto build fail at 1/2 casued unmodified user programs in 1/2. Signed-off-by: Nobuo Iwata <nobuo.iwata@fujixerox.co.jp> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-30USB: usbip: fix potential out-of-bounds writeIgnat Korchagin
Fix potential out-of-bounds write to urb->transfer_buffer usbip handles network communication directly in the kernel. When receiving a packet from its peer, usbip code parses headers according to protocol. As part of this parsing urb->actual_length is filled. Since the input for urb->actual_length comes from the network, it should be treated as untrusted. Any entity controlling the network may put any value in the input and the preallocated urb->transfer_buffer may not be large enough to hold the data. Thus, the malicious entity is able to write arbitrary data to kernel memory. Signed-off-by: Ignat Korchagin <ignat.korchagin@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-03usbip: move usbip_protocol.txt to DocumentationChristian Lamparter
The usbip_protocol.txt, a document which describes usbip's inner workings is currently located in the projects source directory (drivers/usb/usbip/...). This patch moves it to Documentation/usb. This discussion was brought up by Guy Harris [0] during the review of the USBIP dissector I wrote. For anyone interested: support is available with the latest wireshark master/dev tree. Simply select a packet from the usbip's tcp-stream you are intrested on and select the USBIP as the protocol in the "Decode As" dialog box [1]. Signed-off-by: Christian Lamparter <chunkeey@googlemail.com> [0] <https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=12127#c2> [1] <https://www.wireshark.org/docs/wsug_html_chunked/ChCustProtocolDissectionSection.html#ChAdvDecodeAs> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-03usb: usbip: Fix possible deadlocks reported by lockdepAndrew Goodbody
Change spin_lock calls to spin_lock_irqsave to prevent attmpted recursive lock taking in interrupt context. This patch fixes Bug 109351 https://bugzilla.kernel.org/show_bug.cgi?id=109351 Signed-off-by: Andrew Goodbody <andrew.goodbody@cambrionix.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04usbip: vhci_hcd: at unlink, return -EIDRM if vhci_rx took the urbIgor Kotrasinski
In a situation where the urb is about to be returned or was never there, we should return -EIDRM (as per usb_hcd_check_unlink_urb). This is exactly the situation when the urb is picked up by vhci_rx before we access priv. Return -EIDRM rather than 0 when this happens. Signed-off-by: Igor Kotrasinski <i.kotrasinsk@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04usbip: vhci_hcd: only return urb at enqueue when servedIgor Kotrasinski
We handle USB_REQ_SET_ADDRESS at enqueue, so we want to perform cleanup and giveback the urb. We should not call usb_hcd_giveback_urb when we're cleaning up after a failed enqueue, though. Only giveback the urb at cleanup when we claim to have served it. Signed-off-by: Igor Kotrasinski <i.kotrasinsk@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-04usbip: vhci_hcd: Convert use of __constant_cpu_to_le16 to cpu_to_le16Vaishali Thakkar
In big endian cases, macro cpu_to_le16 unfolds to __swab16 which provides special case for constants. In little endian cases, __constant_cpu_to_le16 and cpu_to_le16 expand directly to the same expression. So, replace __constant_cpu_to_le16 with cpu_to_le16 with the goal of getting rid of the definition of __constant_cpu_to_le16 completely. The semantic patch that performs this transformation is as follows: @@expression x;@@ - __constant_cpu_to_le16(x) + cpu_to_le16(x) Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-03usbip: vhci_hcd: use USB_DT_HUBSergei Shtylyov
Fix using the bare number to set the 'bDescriptorType' field of the Hub Descriptor while the value is #define'd in <linux/usb/ch11.h>. Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Acked-by: Valentina Manea <valentina.manea.m@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>