[PATCH 6/6] libata: Check per device max cdb length for SAS

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

 



Since libata does not own any scsi_host struct for
SAS attached SATA devices, libata cannot rely on scsi
core checking the max_cmd_len. This patch adds additional
checking into the SAS queuecommand path to prevent
too large of a cdb from being issued to an ATA or ATAPI device.

Signed-off-by: Brian King <brking@xxxxxxxxxx>
---

 libata-dev-bjking1/drivers/scsi/libata-scsi.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff -puN drivers/scsi/libata-scsi.c~libata_sas_cdb_len drivers/scsi/libata-scsi.c
--- libata-dev/drivers/scsi/libata-scsi.c~libata_sas_cdb_len	2006-06-12 14:19:39.000000000 -0500
+++ libata-dev-bjking1/drivers/scsi/libata-scsi.c	2006-06-12 14:20:34.000000000 -0500
@@ -3206,9 +3206,13 @@ int ata_sas_queuecmd(struct scsi_cmnd *c
 {
 	ata_scsi_dump_cdb(ap, cmd);
 
-	if (likely(ata_scsi_dev_enabled(ap->device)))
-		__ata_scsi_queuecmd(cmd, done, ap->device);
-	else {
+	if (likely(ata_scsi_dev_enabled(ap->device))) {
+		if (unlikely(cmd->cmd_len > ap->device->cdb_len)) {
+			cmd->result = (DID_ABORT << 16);
+			done(cmd);
+		} else
+			__ata_scsi_queuecmd(cmd, done, ap->device);
+	} else {
 		cmd->result = (DID_BAD_TARGET << 16);
 		done(cmd);
 	}
_
-
: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux