summaryrefslogtreecommitdiff
path: root/drivers/usb/class
AgeCommit message (Collapse)Author
2017-04-25USB: Revert "cdc-wdm: fix "out-of-sync" due to missing notifications"Bjørn Mork
This reverts commit 833415a3e781 ("cdc-wdm: fix "out-of-sync" due to missing notifications") There have been several reports of wdm_read returning unexpected EIO errors with QMI devices using the qmi_wwan driver. The reporters confirm that reverting prevents these errors. I have been unable to reproduce the bug myself, and have no explanation to offer either. But reverting is the safe choice here, given that the commit was an attempt to work around a firmware problem. Living with a firmware problem is still better than adding driver bugs. Reported-by: Kasper Holtze <kasper@holtze.dk> Reported-by: Aleksander Morgado <aleksander@aleksander.es> Reported-by: Daniele Palmas <dnlplm@gmail.com> Cc: <stable@vger.kernel.org> # v4.9+ Fixes: 833415a3e781 ("cdc-wdm: fix "out-of-sync" due to missing notifications") Signed-off-by: Bjørn Mork <bjorn@mork.no> Acked-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-18usb: fix some references for /proc/bus/usbMauro Carvalho Chehab
Since when we got rid of usbfs, the /proc/bus/usb is now elsewhere. Fix references for it. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Acked-by: Serge Hallyn <serge@hallyn.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-01cdc-acm: remove unused element of struct acmTobias Herzog
write_used was introduced with commit 884b600f63dc ("[PATCH] USB: fix acm trouble with terminals") but never used since. Signed-off-by: Tobias Herzog <t-herzog@gmx.de> Acked-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-01cdc-acm: log message for serial state notificationTobias Herzog
Adds a similar log message to USB_CDC_NOTIFY_SERIAL_STATE as it is already done with USB_CDC_NOTIFY_NETWORK_CONNECTION. Signed-off-by: Tobias Herzog <t-herzog@gmx.de> Acked-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-01cdc-acm: reassemble fragmented notificationsTobias Herzog
USB devices may have very limited endpoint packet sizes, so that notifications can not be transferred within one single usb packet. Reassembling of multiple packages may be necessary. Signed-off-by: Tobias Herzog <t-herzog@gmx.de> Acked-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-01cdc-acm: fix possible invalid access when processing notificationTobias Herzog
Notifications may only be 8 bytes long. Accessing the 9th and 10th byte of unimplemented/unknown notifications may be insecure. Also check the length of known notifications before accessing anything behind the 8th byte. Signed-off-by: Tobias Herzog <t-herzog@gmx.de> Acked-by: Oliver Neukum <oneukum@suse.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-29USB: usbtmc: refactor endpoint retrievalJohan Hovold
Use the new endpoint helpers to lookup the required bulk-in and bulk-out endpoints, and the optional interrupt-in endpoint. Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-27Merge 4.11-rc4 into usb-nextGreg Kroah-Hartman
This resolves a merge issue in the gadget code, and we want the USB fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-23USB: usblp: refactor endpoint retrievalJohan Hovold
Use the new endpoint helpers to lookup the required bulk-out endpoint and the depending on protocol likewise required bulk-in endpoint. Cc: Pete Zaitcev <zaitcev@redhat.com> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-23USB: cdc-acm: refactor endpoint retrievalJohan Hovold
Use the new endpoint helpers to lookup the required bulk-in, bulk-out and interrupt-in endpoints for collapsed interfaces. Note that there is already a check verifying that there are exactly three endpoints so we'd still be bailing out if there's an unexpected endpoint type. Cc: Oliver Neukum <oneukum@suse.com> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-17USB: usbtmc: fix probe error pathJohan Hovold
Make sure to initialise the return value to avoid having allocation failures going unnoticed when allocating interrupt-endpoint resources. This prevents use-after-free or worse when the device is later unbound. Fixes: dbf3e7f654c0 ("Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation.") Cc: stable <stable@vger.kernel.org> # 4.6 Cc: Dave Penkler <dpenkler@gmail.com> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-17USB: usbtmc: add missing endpoint sanity checkJohan Hovold
USBTMC devices are required to have a bulk-in and a bulk-out endpoint, but the driver failed to verify this, something which could lead to the endpoint addresses being taken from uninitialised memory. Make sure to zero all private data as part of allocation, and add the missing endpoint sanity check. Note that this also addresses a more recently introduced issue, where the interrupt-in-presence flag would also be uninitialised whenever the optional interrupt-in endpoint is not present. This in turn could lead to an interrupt urb being allocated, initialised and submitted based on uninitialised values. Fixes: dbf3e7f654c0 ("Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation.") Fixes: 5b775f672cc9 ("USB: add USB test and measurement class driver") Cc: stable <stable@vger.kernel.org> # 2.6.28 Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-02sched/headers: Prepare to move signal wakeup & sigpending methods from ↵Ingo Molnar
<linux/sched.h> into <linux/sched/signal.h> Fix up affected files that include this signal functionality via sched.h. 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-15usb: cdc-wdm: remove logically dead codeGustavo A. R. Silva
Remove logically dead code. 'cntr' is always equal to zero when the following line of code is executed: rv = cntr ? cntr : -EAGAIN; Addresses-Coverity-ID: 113227 Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> Acked-by: Oliver Neukum <oneukum@suse.com> Reviewed-by: Peter Senna Tschudin <peter.senna@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-26USB: cdc-acm: fix TIOCGSERIAL flagsJohan Hovold
The driver reports that it always uses a low-latency mode by returning the ASYNC_LOW_LATENCY flag through TIOCGSERIAL. Even if this behaviour could not be changed, this may have made some sense prior to 7a9a65ced11e ("cdc-acm: Fix long standing abuse of tty->low_latency") which removed the unconditional setting of the corresponding tty low_latency flag (something which had always been broken in itself). Since the driver does not have a low-latency mode, let's drop the flag. Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-12-05USB: cdc-acm: add device id for GW Instek AFG-125Nathaniel Quillin
Add device-id entry for GW Instek AFG-125, which has a byte swapped bInterfaceSubClass (0x20). Signed-off-by: Nathaniel Quillin <ndq@google.com> Acked-by: Oliver Neukum <oneukum@suse.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-21cdc-acm: handle read pipe errorsLadislav Michl
Read urbs are submitted back only on success, causing read pipe running out of urbs after few errors. No more characters can be read from tty device then until it is reopened and no errors are reported. Fix that by always submitting urbs back and clearing stall on -EPIPE. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Acked-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-21cdc-acm: remove is_int_ep from acm structureLadislav Michl
is_int_ep is used only in acm_probe, no need to store it in device data. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Acked-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-21cdc-acm: store in and out pipes in acm structureLadislav Michl
Clearing stall needs pipe descriptor, store it in acm structure. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Acked-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-21cdc-acm: refactor killing urbsLadislav Michl
Move urb killing code into separate function and use it instead of copying that code pattern over. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Acked-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-21cdc-acm: avoid interface_to_usbdev callLadislav Michl
Pointer to usb_device is already stored in acm structure. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Acked-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-21cdc-acm: reindent log messagesLadislav Michl
Use only one tab to indent dev_{(v)dbg,err} parameters. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Acked-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-14Merge 4.9-rc5 into usb-nextGreg Kroah-Hartman
We want/need the USB fixes in here as well, for testing and merge issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-10USB: cdc-acm: use get_icount tty operationJohan Hovold
Use the tty get_icount operation instead of implementing TIOCGICOUNT directly. Signed-off-by: Johan Hovold <johan@kernel.org> Acked-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-10USB: cdc-acm: fix invalid user-pointer checkJohan Hovold
Drop invalid user-pointer check from TIOCGSERIAL handler. A NULL-pointer can be valid in user space and copy_to_user() takes care of sanity checking. Signed-off-by: Johan Hovold <johan@kernel.org> Acked-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-10USB: cdc-acm: fix TIOCMIWAITJohan Hovold
The TIOCMIWAIT implementation would return -EINVAL if any of the three supported signals were included in the mask. Instead of returning an error in case TIOCM_CTS is included, simply drop the mask check completely, which is in accordance with how other drivers implement this ioctl. Fixes: 5a6a62bdb925 ("cdc-acm: add TIOCMIWAIT") Cc: stable <stable@vger.kernel.org> Signed-off-by: Johan Hovold <johan@kernel.org> Acked-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-07cdc-acm: fix uninitialized variableOliver Neukum
variable struct usb_cdc_parsed_header h may be used uninitialized in acm_probe. In kernel 4.8. /* handle quirks deadly to normal probing*/ if (quirks == NO_UNION_NORMAL) ... goto skip_normal_probe; } we bypass call to cdc_parse_cdc_header(&h, intf, buffer, buflen); but later use h in if (h.usb_cdc_country_functional_desc) { /* export the country data */ Signed-off-by: Oliver Neukum <oneukum@suse.com> CC: stable@vger.kernel.org Reported-by: Victor Sologoubov <victor0@rambler.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-24usbtmc: Add, clarify and fix commentsDave Penkler
Add information regarding lifespan of kref protection: Clarify comment on kref_get for interrupt in urb in usbtmc_probe() Add comment on kref_get in usbtmc_open() Fix endpoint reference in documentation for send_request_dev_dep_msg_in() Signed-off-by: Dave Penkler <dpenkler@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-28Revert "usbtmc: convert to devm_kzalloc"Greg Kroah-Hartman
This reverts commit e6c7efdcb76f11b04e3d3f71c8d764ab75c9423b. Turns out it was totally wrong. The memory is supposed to be bound to the kref, as the original code was doing correctly, not the device/driver binding as the devm_kzalloc() would cause. This fixes an oops when read would be called after the device was unbound from the driver. Reported-by: Ladislav Michl <ladis@linux-mips.org> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: stable <stable@vger.kernel.org> # 3.12+ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-21cdc-acm: hardening against malicious devicesOliver Neukum
This should fix the last holes against malicious devices still open in cdc-acm. It cannot go into stable due to the introduction of the common parser. The fix for stable already merged also covers the problems this patch fixes. Signed-off-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-13cdc-acm: cleaning up debug in data submission pathOliver Neukum
Further cleanup making the debug messages more precise, useful and removing mere trace points. Signed-off-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-13cdc-acm: cleanup debugging in submission pathOliver Neukum
Actually make it retutn useful information. Signed-off-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-09cdc-acm: delete obsolete debug messagesOliver Neukum
Some debug messages merely provide a function trace without additional debug data. They predate ftrace and can be replaced by it. Drop them without replacement. Signed-off-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-09cdc-wdm: add terminating newlineOliver Neukum
Debug messages should be properly terminated. Signed-off-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-30usb: class: usbtmc: don't print on ENOMEMWolfram Sang
All kmalloc-based functions print enough information on failures. Signed-off-by: Wolfram Sang <wsa-dev@sang-engineering.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21Merge 4.8-rc3 into usb-nextGreg Kroah-Hartman
We want the USB fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-15cdc-acm: fix wrong pipe type on rx interrupt xfersGavin Li
This fixes the "BOGUS urb xfer" warning logged by usb_submit_urb(). Signed-off-by: Gavin Li <git@thegavinli.com> Acked-by: Oliver Neukum <oneukum@suse.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-15cdc-wdm: cleanup debug messagesOliver Neukum
Dynamic debugging will already add the function (and the line number) to a debug message if one requests that. It makes no sense to add them unconditionally in a driver. Signed-off-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-15usb: class: usbtmc: 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-10cdc-wdm: Clear read pipeline in case of errorRobert Foss
Implemented queued response handling. This queue is processed every time the WDM_READ flag is cleared. In case of a read error, userspace may not actually read the data, since the driver returns an error through wdm_poll. After this, the underlying device may attempt to send us more data, but the queue is not processed. While userspace is also blocked, because the read error is never cleared. After this patch, we proactively process the queue on a read error. If there was an outstanding response to handle, that will clear the error (or go through the same logic again, if another read error occurs). If there was no outstanding response, this will bring the queue size back to 0, unblocking a future response from the underlying device. Signed-off-by: Robert Foss <robert.foss@collabora.com> Tested-by: Robert Foss <robert.foss@collabora.com> Acked-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-09cdc-wdm: fix "out-of-sync" due to missing notificationsBjørn Mork
The driver enforces a strict one-to-one relationship between the received RESPONSE_AVAILABLE notifications and messages read from the device. At the same time, it will cancel the interrupt URB when there is no client holding the character device open. Many devices do not cope well with this behaviour. They maintain a FIFO queue of messages, and send notifications on a best effort basis. Messages are queued regardless of whether the notification is successful or not. So if the driver loses a single notification, which can easily happen when the interrupt URB is cancelled, then the device and driver becomes out-of-sync. New messages end up at the end of the queue, while the associated notification makes the driver read only the first message from the queue. This state is permanent from a user point of view. There is no no way to flush the device queue without resetting the device or using another driver. The problem is easy to hit with current QMI and MBIM command line tools, which typically close the character device after seeing the reply they expect. Any pending unsolicited messages from the device will then trigger the driver bug. Fix by always reading all queued messages from the device when the notification URB is first submitted. This is expected to end with an -EPIPE status when there are no more pending messages, so demote the printk associated with -EPIPE to debug level. The workaround has been tested on a large number of different MBIM and QMI devices, as well as the Ericsson F5521gw and H5321gw modems with real Device Management functions. Signed-off-by: Bjørn Mork <bjorn@mork.no> Acked-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-07-18cdc-acm: beautify probe()Oliver Neukum
This removes some overly long lines by renaming variables and giving them local scope. Signed-off-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-07-18cdc-wdm: use the common CDC parserOliver Neukum
Now that the common parser resides in USB core, it can be used for CDC-WDM. Signed-off-by: Oliver Neukum <ONeukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-07-18cdc-acm: cleanup error handlingOliver Neukum
A small update to unify error handling during probe(). Signed-off-by: Oliver Neukum <ONeukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-07-18cdc-acm: use the common parserOliver Neukum
This introduces the common parser for extra CDC headers now that it no longer depends on usbnet. Signed-off-by: Oliver Neukum <ONeukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-07usb: cdc-acm: Space prohibited before close parenthesis ')'.Sandhya Bankar
Space prohibited before close parenthesis ')'. Signed-off-by: Sandhya Bankar <bankarsandhya512@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30tty: Replace ASYNC_INITIALIZED bit and update atomicallyPeter Hurley
Replace ASYNC_INITIALIZED bit in the tty_port::flags field with TTY_PORT_INITIALIZED bit in the tty_port::iflags field. Introduce helpers tty_port_set_initialized() and tty_port_initialized() to abstract atomic bit ops. Note: the transforms for test_and_set_bit() and test_and_clear_bit() are unnecessary as the state transitions are already mutually exclusive; the tty lock prevents concurrent open/close/hangup. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-13cdc-acm: fix crash if flushed with nothing bufferedOliver Neukum
Under some circumstances acm_tty_flush_chars() is called with no buffer to flush. We simply need to do nothing. Signed-off-by: Oliver Neukum <ONeukum@suse.com> Reported-by: Torsten Hilbrich <torsten.hilbrich@secunet.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-18USB: cdc-acm: more sanity checkingOliver Neukum
An attack has become available which pretends to be a quirky device circumventing normal sanity checks and crashes the kernel by an insufficient number of interfaces. This patch adds a check to the code path for quirky devices. Signed-off-by: Oliver Neukum <ONeukum@suse.com> CC: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-20usb: usbtmc: Fix disconnect/poll interactionDave Penkler
When the device is disconnected poll waiters were not being woken. Changes for v2: - add commit summary - add Fixes and Reported-by tags Fixes: eb6b92ecc0f9 ("Add support for receiving USBTMC USB488 SRQ notifications via poll/select") Reported-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Dave Penkler <dpenkler@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>