* [PATCH 0/2] ZBC_OUT command translation fixes @ 2018-06-26 7:18 Damien Le Moal 2018-06-26 7:18 ` [PATCH 1/2] ata: Fix ZBC_OUT command block check Damien Le Moal 2018-06-26 7:18 ` [PATCH 2/2] ata: Fix ZBC_OUT all bit handling Damien Le Moal 0 siblings, 2 replies; 5+ messages in thread From: Damien Le Moal @ 2018-06-26 7:18 UTC (permalink / raw) To: Tejun Heo, linux-ide Cc: linux-scsi, Martin K . Petersen, Bart Van Assche, Hannes Reinecke, stable Tejun, These two patches fix problems with the checks of the ZBC_OUT command fields prior to its translation to ZAC MANAGEMENT OUT. The first patch fixes an incorrect out-of-range check and changes the returned asc/ascq to the ZBC defined INVALID FIELD IN CDB instead of (the more natural but incorrect) LBA OUT OF RANGE. The second patch disables the ZBC_OUT command block address check if the ALL bit is set, as defined by the ZBC specifications. Thank you for considering these patches for inclusion in 4.18 fixes (and CC stable). Damien Le Moal (2): ata: Fix ZBC_OUT command block check ata: Fix ZBC_OUT all bit handling drivers/ata/libata-scsi.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) -- 2.17.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] ata: Fix ZBC_OUT command block check 2018-06-26 7:18 [PATCH 0/2] ZBC_OUT command translation fixes Damien Le Moal @ 2018-06-26 7:18 ` Damien Le Moal 2018-06-26 11:38 ` Greg KH 2018-06-26 7:18 ` [PATCH 2/2] ata: Fix ZBC_OUT all bit handling Damien Le Moal 1 sibling, 1 reply; 5+ messages in thread From: Damien Le Moal @ 2018-06-26 7:18 UTC (permalink / raw) To: Tejun Heo, linux-ide Cc: linux-scsi, Martin K . Petersen, Bart Van Assche, Hannes Reinecke, stable The block (LBA) specified must not exceed the last addressable LBA, which is dev->nr_sectors - 1. So fix the correct check is "if (block >= dev->n_sectors)" and not "if (block > dev->n_sectords)". Additionally, the asc/ascq to return for an LBA that is not a zone start LBA should be ILLEGAL REQUEST, regardless if the bad LBA is out of range. Reported-by: David Butterfield <david.butterfield@wdc.com> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> --- drivers/ata/libata-scsi.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 6a91d04351d9..a5543751f446 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -3805,8 +3805,13 @@ static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc) */ goto invalid_param_len; } - if (block > dev->n_sectors) - goto out_of_range; + if (block >= dev->n_sectors) { + /* + * Block must be a valid zone ID (a zone start LBA). + */ + fp = 2; + goto invalid_fld; + } all = cdb[14] & 0x1; @@ -3837,10 +3842,6 @@ static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc) invalid_fld: ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); return 1; - out_of_range: - /* "Logical Block Address out of range" */ - ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x21, 0x00); - return 1; invalid_param_len: /* "Parameter list length error" */ ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0); -- 2.17.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] ata: Fix ZBC_OUT command block check 2018-06-26 7:18 ` [PATCH 1/2] ata: Fix ZBC_OUT command block check Damien Le Moal @ 2018-06-26 11:38 ` Greg KH 0 siblings, 0 replies; 5+ messages in thread From: Greg KH @ 2018-06-26 11:38 UTC (permalink / raw) To: Damien Le Moal Cc: Tejun Heo, linux-ide, linux-scsi, Martin K . Petersen, Bart Van Assche, Hannes Reinecke, stable On Tue, Jun 26, 2018 at 04:18:37PM +0900, Damien Le Moal wrote: > The block (LBA) specified must not exceed the last addressable LBA, > which is dev->nr_sectors - 1. So fix the correct check is > "if (block >= dev->n_sectors)" and not "if (block > dev->n_sectords)". > > Additionally, the asc/ascq to return for an LBA that is not a zone start > LBA should be ILLEGAL REQUEST, regardless if the bad LBA is out of > range. > > Reported-by: David Butterfield <david.butterfield@wdc.com> > Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> <formletter> This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly. </formletter> ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] ata: Fix ZBC_OUT all bit handling 2018-06-26 7:18 [PATCH 0/2] ZBC_OUT command translation fixes Damien Le Moal 2018-06-26 7:18 ` [PATCH 1/2] ata: Fix ZBC_OUT command block check Damien Le Moal @ 2018-06-26 7:18 ` Damien Le Moal 2018-06-26 11:38 ` Greg KH 1 sibling, 1 reply; 5+ messages in thread From: Damien Le Moal @ 2018-06-26 7:18 UTC (permalink / raw) To: Tejun Heo, linux-ide Cc: linux-scsi, Martin K . Petersen, Bart Van Assche, Hannes Reinecke, stable If the ALL bit is set in the ZBC_OUT command, the command zone ID field (block) should be ignored. Reported-by: David Butterfield <david.butterfield@wdc.com> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> --- drivers/ata/libata-scsi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index a5543751f446..aad1b01447de 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -3805,7 +3805,14 @@ static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc) */ goto invalid_param_len; } - if (block >= dev->n_sectors) { + + all = cdb[14] & 0x1; + if (all) { + /* + * Ignore the block address (zone ID) as defined by ZBC. + */ + block = 0; + } else if (block >= dev->n_sectors) { /* * Block must be a valid zone ID (a zone start LBA). */ @@ -3813,8 +3820,6 @@ static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc) goto invalid_fld; } - all = cdb[14] & 0x1; - if (ata_ncq_enabled(qc->dev) && ata_fpdma_zac_mgmt_out_supported(qc->dev)) { tf->protocol = ATA_PROT_NCQ_NODATA; -- 2.17.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] ata: Fix ZBC_OUT all bit handling 2018-06-26 7:18 ` [PATCH 2/2] ata: Fix ZBC_OUT all bit handling Damien Le Moal @ 2018-06-26 11:38 ` Greg KH 0 siblings, 0 replies; 5+ messages in thread From: Greg KH @ 2018-06-26 11:38 UTC (permalink / raw) To: Damien Le Moal Cc: Tejun Heo, linux-ide, linux-scsi, Martin K . Petersen, Bart Van Assche, Hannes Reinecke, stable On Tue, Jun 26, 2018 at 04:18:38PM +0900, Damien Le Moal wrote: > If the ALL bit is set in the ZBC_OUT command, the command zone ID field > (block) should be ignored. > > Reported-by: David Butterfield <david.butterfield@wdc.com> > Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> > --- > drivers/ata/libata-scsi.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) <formletter> This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly. </formletter> ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-06-26 11:38 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-06-26 7:18 [PATCH 0/2] ZBC_OUT command translation fixes Damien Le Moal 2018-06-26 7:18 ` [PATCH 1/2] ata: Fix ZBC_OUT command block check Damien Le Moal 2018-06-26 11:38 ` Greg KH 2018-06-26 7:18 ` [PATCH 2/2] ata: Fix ZBC_OUT all bit handling Damien Le Moal 2018-06-26 11:38 ` Greg KH
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.