fix #5448: support SCSI contollers with bad VDP page length encoding again
The reporter has an Adaptec 5805 controller (using the aacraid driver), which reports a byteswapped page length for VPD page 0. It reports "02 00" as page length instead of "00 02". This stopped working with kernel 6.8.4 due to commit b5fc07a5fb56 ("scsi: core: Consult supported VPD page list prior to fetching page") To address that issue limit the page search scope to the size of our VPD buffer to guard against devices returning a larger page count than requested. Reported-by: Peter Schneider <pschneider1968@googlemail.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
8b2b863fa7
commit
77af8d24c4
@ -0,0 +1,49 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Martin K. Petersen" <martin.petersen@oracle.com>
|
||||
Date: Mon, 20 May 2024 22:30:40 -0400
|
||||
Subject: [PATCH] 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
|
||||
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/20240521023040.2703884-1-martin.petersen@oracle.com
|
||||
Fixes: b5fc07a5fb56 ("scsi: core: Consult supported VPD page list prior to fetching page")
|
||||
Cc: stable@vger.kernel.org
|
||||
Reported-by: Peter Schneider <pschneider1968@googlemail.com>
|
||||
Closes: https://lore.kernel.org/all/eec6ebbf-061b-4a7b-96dc-ea748aa4d035@googlemail.com/
|
||||
Tested-by: Peter Schneider <pschneider1968@googlemail.com>
|
||||
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
|
||||
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
|
||||
---
|
||||
drivers/scsi/scsi.c | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
|
||||
index 8cad9792a562..b3ff3a633a1e 100644
|
||||
--- a/drivers/scsi/scsi.c
|
||||
+++ b/drivers/scsi/scsi.c
|
||||
@@ -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;
|
Loading…
Reference in New Issue
Block a user