Skip to content

Commit d09c05a

Browse files
scsi: core: Handle devices which return an unusually large VPD page count
Peter Schneider reported that a system would no longer boot after updating to 6.8.4. Peter bisected the issue and identified commit b5fc07a ("scsi: core: Consult supported VPD page list prior to fetching page") as being the culprit. Turns out the enclosure device in Peter's system reports a byteswapped page length for VPD page 0. It reports "02 00" as page length instead of "00 02". This causes us to attempt to access 516 bytes (page length + header) of information despite only 2 pages being present. Limit the page search scope to the size of our VPD buffer to guard against devices returning a larger page count than requested. Link: https://lore.kernel.org/r/[email protected] Fixes: b5fc07a ("scsi: core: Consult supported VPD page list prior to fetching page") Cc: [email protected] Reported-by: Peter Schneider <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Tested-by: Peter Schneider <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent e4f5f82 commit d09c05a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/scsi/scsi.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,13 @@ static int scsi_get_vpd_size(struct scsi_device *sdev, u8 page)
350350
if (result < SCSI_VPD_HEADER_SIZE)
351351
return 0;
352352

353+
if (result > sizeof(vpd)) {
354+
dev_warn_once(&sdev->sdev_gendev,
355+
"%s: long VPD page 0 length: %d bytes\n",
356+
__func__, result);
357+
result = sizeof(vpd);
358+
}
359+
353360
result -= SCSI_VPD_HEADER_SIZE;
354361
if (!memchr(&vpd[SCSI_VPD_HEADER_SIZE], page, result))
355362
return 0;

0 commit comments

Comments
 (0)