SCSI: sd: Fix potential out-of-bounds access
authorAlan Stern <stern@rowland.harvard.edu>
Fri, 6 Sep 2013 15:49:51 +0000 (11:49 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Sep 2013 00:21:35 +0000 (17:21 -0700)
commit9ed42ce59457ba8df30d345278f3c079ca61b595
tree19008129e0d9a9092c71f647c39c465752fd103d
parentadb34ef814140689c6996e511cec807145774ff9
SCSI: sd: Fix potential out-of-bounds access

commit 984f1733fcee3fbc78d47e26c5096921c5d9946a upstream.

This patch fixes an out-of-bounds error in sd_read_cache_type(), found
by Google's AddressSanitizer tool.  When the loop ends, we know that
"offset" lies beyond the end of the data in the buffer, so no Caching
mode page was found.  In theory it may be present, but the buffer size
is limited to 512 bytes.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/scsi/sd.c