Skip to content

Commit d657700

Browse files
scsi: core: Do not truncate INQUIRY data on modern devices
Low-level device drivers have had the ability to limit the size of an INQUIRY for many years. This made sense for a wide variety of legacy devices. However, we are unnecessarily truncating the INQUIRY response for many modern devices. This prevents us from consulting fields beyond the first 36 bytes. If a device reports that it supports a larger INQUIRY response, and the device also reports that it implements SPC-4 or newer, allow the larger INQUIRY to proceed. Link: https://lore.kernel.org/r/20220302053559.32147-4-martin.petersen@oracle.com Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent e60ac0b commit d657700

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/scsi/scsi_scan.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,17 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
733733
if (pass == 1) {
734734
if (BLIST_INQUIRY_36 & *bflags)
735735
next_inquiry_len = 36;
736-
else if (sdev->inquiry_len)
736+
/*
737+
* LLD specified a maximum sdev->inquiry_len
738+
* but device claims it has more data. Capping
739+
* the length only makes sense for legacy
740+
* devices. If a device supports SPC-4 (2014)
741+
* or newer, assume that it is safe to ask for
742+
* as much as the device says it supports.
743+
*/
744+
else if (sdev->inquiry_len &&
745+
response_len > sdev->inquiry_len &&
746+
(inq_result[2] & 0x7) < 6) /* SPC-4 */
737747
next_inquiry_len = sdev->inquiry_len;
738748
else
739749
next_inquiry_len = response_len;

0 commit comments

Comments
 (0)