]> www.infradead.org Git - users/jedix/linux-maple.git/commit
USB: uas: fix bug in handling of alternate settings
authorAlan Stern <stern@rowland.harvard.edu>
Fri, 22 Sep 2017 15:56:49 +0000 (11:56 -0400)
committerTim Tianyang Chen <tianyang.chen@oracle.com>
Fri, 8 Dec 2017 17:31:35 +0000 (09:31 -0800)
commitade96e7b18cc26baadc61bea5041c7a2e0185982
tree76b8a9aebbed6beb1457990b7bb131b91fa923af
parentd96302a3e1e36efcc8741f35bfd83c83bd2134a7
USB: uas: fix bug in handling of alternate settings

The uas driver has a subtle bug in the way it handles alternate
settings.  The uas_find_uas_alt_setting() routine returns an
altsetting value (the bAlternateSetting number in the descriptor), but
uas_use_uas_driver() then treats that value as an index to the
intf->altsetting array, which it isn't.

Normally this doesn't cause any problems because the various
alternate settings have bAlternateSetting values 0, 1, 2, ..., so the
value is equal to the index in the array.  But this is not guaranteed,
and Andrey Konovalov used the syzkaller fuzzer with KASAN to get a
slab-out-of-bounds error by violating this assumption.

This patch fixes the bug by making uas_find_uas_alt_setting() return a
pointer to the altsetting entry rather than either the value or the
index.  Pointers are less subject to misinterpretation.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
CC: Oliver Neukum <oneukum@suse.com>
CC: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 786de92b3cb26012d3d0f00ee37adf14527f35c4)

Orabug: 27206993
CVE: CVE-2017-16530

Signed-off-by: Tim Tianyang Chen <tianyang.chen@oracle.com>
Reviewed-by: Reviewed-by: Jack Vogel <jack.vogel@oracle.com>
drivers/usb/storage/uas-detect.h
drivers/usb/storage/uas.c