]> Git Repo - linux.git/commitdiff
scsi: core: Handle devices which return an unusually large VPD page count
authorMartin K. Petersen <[email protected]>
Tue, 21 May 2024 02:30:40 +0000 (22:30 -0400)
committerMartin K. Petersen <[email protected]>
Fri, 24 May 2024 00:35:32 +0000 (20:35 -0400)
Peter Schneider reported that a system would no longer boot after
updating to 6.8.4.  Peter bisected the issue and identified commit
b5fc07a5fb56 ("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: b5fc07a5fb56 ("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]>
drivers/scsi/scsi.c

index 3e0c0381277acd7aed4afdbf3fc7433ef2568868..f0464db3f9de99fbae94c0522505a950a484dac0 100644 (file)
@@ -350,6 +350,13 @@ static int scsi_get_vpd_size(struct scsi_device *sdev, u8 page)
                if (result < SCSI_VPD_HEADER_SIZE)
                        return 0;
 
+               if (result > sizeof(vpd)) {
+                       dev_warn_once(&sdev->sdev_gendev,
+                                     "%s: long VPD page 0 length: %d bytes\n",
+                                     __func__, result);
+                       result = sizeof(vpd);
+               }
+
                result -= SCSI_VPD_HEADER_SIZE;
                if (!memchr(&vpd[SCSI_VPD_HEADER_SIZE], page, result))
                        return 0;
This page took 0.194117 seconds and 4 git commands to generate.