• Alan Stern's avatar
    USB: gadgetfs: fix checks of wTotalLength in config descriptors · 002079e8
    Alan Stern authored
    commit 1c069b05 upstream.
    
    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: default avatarAlan Stern <stern@rowland.harvard.edu>
    CC: Andrey Konovalov <andreyknvl@google.com>
    Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
    [bwh: Backported to 3.16: adjust filename]
    Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
    002079e8
inode.c 52.7 KB