提交 a5214c26 编写于 作者: G George Kennedy 提交者: Zheng Zengkai

libata: if T_LENGTH is zero, dma direction should be DMA_NONE

stable inclusion
from stable-v5.10.88
commit c1d519263ded9a51560420e6c4a42fb02cc8c478
bugzilla: 186058 https://gitee.com/openeuler/kernel/issues/I4QW6A

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=c1d519263ded9a51560420e6c4a42fb02cc8c478

--------------------------------

commit 5da5231b upstream.

Avoid data corruption by rejecting pass-through commands where
T_LENGTH is zero (No data is transferred) and the dma direction
is not DMA_NONE.

Cc: <stable@vger.kernel.org>
Reported-by: syzkaller<syzkaller@googlegroups.com>
Signed-off-by: George Kennedy<george.kennedy@oracle.com>
Signed-off-by: NDamien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 5843d915
...@@ -2878,8 +2878,19 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) ...@@ -2878,8 +2878,19 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
goto invalid_fld; goto invalid_fld;
} }
if (ata_is_ncq(tf->protocol) && (cdb[2 + cdb_offset] & 0x3) == 0) if ((cdb[2 + cdb_offset] & 0x3) == 0) {
tf->protocol = ATA_PROT_NCQ_NODATA; /*
* When T_LENGTH is zero (No data is transferred), dir should
* be DMA_NONE.
*/
if (scmd->sc_data_direction != DMA_NONE) {
fp = 2 + cdb_offset;
goto invalid_fld;
}
if (ata_is_ncq(tf->protocol))
tf->protocol = ATA_PROT_NCQ_NODATA;
}
/* enable LBA */ /* enable LBA */
tf->flags |= ATA_TFLAG_LBA; tf->flags |= ATA_TFLAG_LBA;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册