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-27 14:43:35.000000000 -0500 +++ libata-dev-bjking1/drivers/scsi/libata-scsi.c 2006-06-27 14:43:35.000000000 -0500 @@ -3207,9 +3207,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