From: Greg Kroah-Hartman Date: Mon, 8 Jul 2019 14:01:20 +0000 (+0200) Subject: 5.1-stable patches X-Git-Tag: v5.1.17~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2f500852a70218167c7e09826002e0979394cac2;p=thirdparty%2Fkernel%2Fstable-queue.git 5.1-stable patches added patches: scsi-target-iblock-fix-overrun-in-write-same-emulation.patch --- diff --git a/queue-5.1/scsi-target-iblock-fix-overrun-in-write-same-emulation.patch b/queue-5.1/scsi-target-iblock-fix-overrun-in-write-same-emulation.patch new file mode 100644 index 00000000000..c0705a13b71 --- /dev/null +++ b/queue-5.1/scsi-target-iblock-fix-overrun-in-write-same-emulation.patch @@ -0,0 +1,42 @@ +From 5676234f20fef02f6ca9bd66c63a8860fce62645 Mon Sep 17 00:00:00 2001 +From: Roman Bolshakov +Date: Tue, 2 Jul 2019 22:16:38 +0300 +Subject: scsi: target/iblock: Fix overrun in WRITE SAME emulation + +From: Roman Bolshakov + +commit 5676234f20fef02f6ca9bd66c63a8860fce62645 upstream. + +WRITE SAME corrupts data on the block device behind iblock if the command +is emulated. The emulation code issues (M - 1) * N times more bios than +requested, where M is the number of 512 blocks per real block size and N is +the NUMBER OF LOGICAL BLOCKS specified in WRITE SAME command. So, for a +device with 4k blocks, 7 * N more LBAs gets written after the requested +range. + +The issue happens because the number of 512 byte sectors to be written is +decreased one by one while the real bios are typically from 1 to 8 512 byte +sectors per bio. + +Fixes: c66ac9db8d4a ("[SCSI] target: Add LIO target core v4.0.0-rc6") +Cc: +Signed-off-by: Roman Bolshakov +Reviewed-by: Bart Van Assche +Signed-off-by: Martin K. Petersen +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/target/target_core_iblock.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/target/target_core_iblock.c ++++ b/drivers/target/target_core_iblock.c +@@ -515,7 +515,7 @@ iblock_execute_write_same(struct se_cmd + + /* Always in 512 byte units for Linux/Block */ + block_lba += sg->length >> SECTOR_SHIFT; +- sectors -= 1; ++ sectors -= sg->length >> SECTOR_SHIFT; + } + + iblock_submit_bios(&list); diff --git a/queue-5.1/series b/queue-5.1/series index 3ee5a7a6315..8d32c0b831f 100644 --- a/queue-5.1/series +++ b/queue-5.1/series @@ -93,3 +93,4 @@ dmaengine-qcom-bam_dma-fix-completed-descriptors-count.patch dmaengine-imx-sdma-remove-bd_intr-for-channel0.patch dmaengine-jz4780-fix-an-endian-bug-in-irq-handler.patch fs-validate_fs_parser-should-default-to-n.patch +scsi-target-iblock-fix-overrun-in-write-same-emulation.patch