]> asedeno.scripts.mit.edu Git - linux.git/commit
USB: core: Fix unterminated string returned by usb_string()
authorAlan Stern <stern@rowland.harvard.edu>
Mon, 15 Apr 2019 15:51:38 +0000 (11:51 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 16 Apr 2019 10:23:01 +0000 (12:23 +0200)
commitc01c348ecdc66085e44912c97368809612231520
treea3e6d51758cdf093bd51f4b44f2dae28d2bcf797
parent79a3aaa7b82e3106be97842dedfd8429248896e6
USB: core: Fix unterminated string returned by usb_string()

Some drivers (such as the vub300 MMC driver) expect usb_string() to
return a properly NUL-terminated string, even when an error occurs.
(In fact, vub300's probe routine doesn't bother to check the return
code from usb_string().)  When the driver goes on to use an
unterminated string, it leads to kernel errors such as
stack-out-of-bounds, as found by the syzkaller USB fuzzer.

An out-of-range string index argument is not at all unlikely, given
that some devices don't provide string descriptors and therefore list
0 as the value for their string indexes.  This patch makes
usb_string() return a properly terminated empty string along with the
-EINVAL error code when an out-of-range index is encountered.

And since a USB string index is a single-byte value, indexes >= 256
are just as invalid as values of 0 or below.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: syzbot+b75b85111c10b8d680f1@syzkaller.appspotmail.com
CC: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/message.c