]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
USB: gadgetfs: fix checks of wTotalLength in config descriptors
authorAlan Stern <stern@rowland.harvard.edu>
Fri, 9 Dec 2016 20:24:24 +0000 (15:24 -0500)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 2 Jan 2017 08:55:28 +0000 (10:55 +0200)
commit1c069b057dcf64fada952eaa868d35f02bb0cfc2
treead1be498fb99e8c558475dc03fa3474bb81ba400
parentadd333a81a16abbd4f106266a2553677a165725f
USB: gadgetfs: fix checks of wTotalLength in config descriptors

Andrey Konovalov's fuzz testing of gadgetfs showed that we should
improve the driver's checks for valid configuration descriptors passed
in by the user.  In particular, the driver needs to verify that the
wTotalLength value in the descriptor is not too short (smaller
than USB_DT_CONFIG_SIZE).  And the check for whether wTotalLength is
too large has to be changed, because the driver assumes there is
always enough room remaining in the buffer to hold a device descriptor
(at least USB_DT_DEVICE_SIZE bytes).

This patch adds the additional check and fixes the existing check.  It
may do a little more than strictly necessary, but one extra check
won't hurt.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Andrey Konovalov <andreyknvl@google.com>
CC: <stable@vger.kernel.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/legacy/inode.c