[RHEL7,COMMIT] ms/target: Fix VERIFY_16 handling in sbc_parse_cdb

Submitted by Konstantin Khorenko on April 2, 2018, 2:28 p.m.

Details

Message ID 201804021428.w32ESJC6023667@finist_ce7.work
State New
Series "target: backport bug fixes from the upstream kernel"
Headers show

Commit Message

Konstantin Khorenko April 2, 2018, 2:28 p.m.
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.46.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.46.2
------>
commit 8c4370283f897faa85c255fa5caddccb314ba8dd
Author: Max Lohrmann <post@wickenrode.com>
Date:   Mon Apr 2 17:28:19 2018 +0300

    ms/target: Fix VERIFY_16 handling in sbc_parse_cdb
    
    ML: 13603685c1f12c67a7a2427f00b63f39a2b6f7c9
    
    As reported by Max, the Windows 2008 R2 chkdsk utility expects
    VERIFY_16 to be supported, and does not handle the returned
    CHECK_CONDITION properly, resulting in an infinite loop.
    
    The kernel will log huge amounts of this error:
    
    kernel: TARGET_CORE[iSCSI]: Unsupported SCSI Opcode 0x8f, sending
    CHECK_CONDITION.
    
    Signed-off-by: Max Lohrmann <post@wickenrode.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
    Signed-off-by: Andrei Vagin <avagin@openvz.org>
---
 drivers/target/target_core_sbc.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index 4be6c69537ae..8a799a8860b7 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -1018,9 +1018,15 @@  sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
 			return ret;
 		break;
 	case VERIFY:
+	case VERIFY_16:
 		size = 0;
-		sectors = transport_get_sectors_10(cdb);
-		cmd->t_task_lba = transport_lba_32(cdb);
+		if (cdb[0] == VERIFY) {
+			sectors = transport_get_sectors_10(cdb);
+			cmd->t_task_lba = transport_lba_32(cdb);
+		} else {
+			sectors = transport_get_sectors_16(cdb);
+			cmd->t_task_lba = transport_lba_64(cdb);
+		}
 		cmd->execute_cmd = sbc_emulate_noop;
 		goto check_lba;
 	case REZERO_UNIT: