• Alan Stern's avatar
    USB: avoid left shift by -1 · c1251c31
    Alan Stern authored
    commit 53e5f36f upstream.
    
    UBSAN complains about a left shift by -1 in proc_do_submiturb().  This
    can occur when an URB is submitted for a bulk or control endpoint on
    a high-speed device, since the code doesn't bother to check the
    endpoint type; normally only interrupt or isochronous endpoints have
    a nonzero bInterval value.
    
    Aside from the fact that the operation is illegal, it shouldn't matter
    because the result isn't used.  Still, in theory it could cause a
    hardware exception or other problem, so we should work around it.
    This patch avoids doing the left shift unless the shift amount is >= 0.
    
    The same piece of code has another problem.  When checking the device
    speed (the exponential encoding for interrupt endpoints is used only
    by high-speed or faster devices), we need to look for speed >=
    USB_SPEED_SUPER as well as speed == USB_SPEED HIGH.  The patch adds
    this check.
    Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
    Reported-by: default avatarVittorio Zecca <zeccav@gmail.com>
    Tested-by: default avatarVittorio Zecca <zeccav@gmail.com>
    Suggested-by: default avatarBjørn Mork <bjorn@mork.no>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
    c1251c31
devio.c 52.7 KB