Message ID | 20180204043351.16812-1-ebiggers3@gmail.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
On Sat, Feb 03, 2018 at 08:33:51PM -0800, Eric Biggers wrote: > From: Eric Biggers <ebiggers@google.com> > > syzkaller hit a WARN() in ata_bmdma_qc_issue() when writing to /dev/sg0. > This happened because it issued an ATA pass-through command (ATA_16) > where the protocol field indicated that NCQ should be used -- but the > device did not support NCQ. > > We could just remove the WARN() from libata-sff.c, but the real problem > seems to be that the SCSI -> ATA translation code passes through NCQ > commands without verifying that the device actually supports NCQ. > > Fix this by adding the appropriate check to ata_scsi_pass_thru(). Applied to libata/for-4.16-fixes. Thanks.
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 47d421666451c..197e110f8ac75 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -3316,6 +3316,12 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) goto invalid_fld; } + /* We may not issue NCQ commands to devices not supporting NCQ */ + if (ata_is_ncq(tf->protocol) && !ata_ncq_enabled(dev)) { + fp = 1; + goto invalid_fld; + } + /* sanity check for pio multi commands */ if ((cdb[1] & 0xe0) && !is_multi_taskfile(tf)) { fp = 1;