Patch "scsi: core: Improve scsi_vpd_inquiry() checks" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    scsi: core: Improve scsi_vpd_inquiry() checks

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     scsi-core-improve-scsi_vpd_inquiry-checks.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 61950e78063f61fcad6aa828cdaa4bf7cfc5cbb0
Author: Damien Le Moal <damien.lemoal@xxxxxxxxxxxxxxxxxx>
Date:   Wed Mar 22 11:22:11 2023 +0900

    scsi: core: Improve scsi_vpd_inquiry() checks
    
    [ Upstream commit f0aa59a33d2ac2267d260fe21eaf92500df8e7b4 ]
    
    Some USB-SATA adapters have broken behavior when an unsupported VPD page is
    probed: Depending on the VPD page number, a 4-byte header with a valid VPD
    page number but with a 0 length is returned. Currently, scsi_vpd_inquiry()
    only checks that the page number is valid to determine if the page is
    valid, which results in receiving only the 4-byte header for the
    non-existent page. This error manifests itself very often with page 0xb9
    for the Concurrent Positioning Ranges detection done by sd_read_cpr(),
    resulting in the following error message:
    
    sd 0:0:0:0: [sda] Invalid Concurrent Positioning Ranges VPD page
    
    Prevent such misleading error message by adding a check in
    scsi_vpd_inquiry() to verify that the page length is not 0.
    
    Signed-off-by: Damien Le Moal <damien.lemoal@xxxxxxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230322022211.116327-1-damien.lemoal@xxxxxxxxxxxxxxxxxx
    Reviewed-by: Benjamin Block <bblock@xxxxxxxxxxxxx>
    Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 1ce3f90f782fd..2921256b59a0e 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -331,11 +331,18 @@ static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
 	if (result)
 		return -EIO;
 
-	/* Sanity check that we got the page back that we asked for */
+	/*
+	 * Sanity check that we got the page back that we asked for and that
+	 * the page size is not 0.
+	 */
 	if (buffer[1] != page)
 		return -EIO;
 
-	return get_unaligned_be16(&buffer[2]) + 4;
+	result = get_unaligned_be16(&buffer[2]);
+	if (!result)
+		return -EIO;
+
+	return result + 4;
 }
 
 /**



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux