lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220103082338.GA28606@lst.de>
Date:   Mon, 3 Jan 2022 09:23:38 +0100
From:   Christoph Hellwig <hch@....de>
To:     "Maciej W. Rozycki" <macro@...am.me.uk>
Cc:     Khalid Aziz <khalid@...ehiking.org>,
        "James E.J. Bottomley" <jejb@...ux.ibm.com>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        Christoph Hellwig <hch@....de>, Nix <nix@...eri.org.uk>,
        linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 1/3] scsi: Provide for avoiding trailing allocation
 length with VPD inquiries

On Sun, Jan 02, 2022 at 11:23:45PM +0000, Maciej W. Rozycki wrote:
> Allow SCSI hosts to request avoiding trailing allocation length with VPD 
> inquiries, and use the mechanism to work around an issue with at least 
> some BusLogic MultiMaster host bus adapters and observed with the BT-958 
> model specifically where issuing commands that return less data than 
> provided for causes fatal failures:

Wouldn't it make more sesnse to hide this quirk insde of
scsi_vpd_inquiry to also handle the scsi_get_vpd_buf case?  Something
like:


diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 211aace69c22c..194a51f772aaa 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -289,8 +289,8 @@ EXPORT_SYMBOL(scsi_track_queue_full);
  *
  * Returns size of the vpd page on success or a negative error number.
  */
-static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
-							u8 page, unsigned len)
+static int __scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
+		u8 page, unsigned len)
 {
 	int result;
 	unsigned char cmd[16];
@@ -321,6 +321,20 @@ static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
 	return get_unaligned_be16(&buffer[2]) + 4;
 }
 
+static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
+		u8 page, unsigned len)
+{
+	if (sdev->host->no_trailing_allocation_length) {
+		int ret = __scsi_vpd_inquiry(sdev, buffer, page, min(4U, len));
+
+		if (ret < 4)
+			return ret;
+		len = min_t(unsigned int, ret, len);
+	}
+
+	return __scsi_vpd_inquiry(sdev, buffer, page, len);
+}
+
 /**
  * scsi_get_vpd_page - Get Vital Product Data from a SCSI device
  * @sdev: The device to ask

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ