]> git.baikalelectronics.ru Git - kernel.git/commit
USB: core: Check buffer length matches wLength for control transfers
authorAlan Stern <stern@rowland.harvard.edu>
Wed, 26 May 2021 15:32:44 +0000 (11:32 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 May 2021 11:46:21 +0000 (13:46 +0200)
commitf7802ad9afc969346a048a9b899f9a14be8f8461
tree1df0b0a80088856a1f208a792c41558d7c4e611d
parent7ba6bfb95f5a1fd358b4fa3537c5d34c7562527f
USB: core: Check buffer length matches wLength for control transfers

A type of inconsistency that can show up in control URBs is when the
setup packet's wLength value does not match the URB's
transfer_buffer_length field.  The two should always be equal;
differences could lead to information leaks or undefined behavior for
OUT transfers or overruns for IN transfers.

This patch adds a test for such mismatches during URB submission.  If
the test fails, the submission is rejected with a -EBADR error code
(which is not used elsewhere in the USB core), and a debugging message
is logged for people interested in tracking down these errors.

Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20210526153244.GA1400430@rowland.harvard.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/driver-api/usb/error-codes.rst
drivers/usb/core/urb.c