OSDN Git Service

target/sbc: Return INVALID_CDB_FIELD if DIF + sess_prot_type disabled
authorNicholas Bellinger <nab@linux-iscsi.org>
Tue, 14 Apr 2015 18:55:01 +0000 (11:55 -0700)
committerNicholas Bellinger <nab@linux-iscsi.org>
Thu, 16 Apr 2015 05:47:15 +0000 (22:47 -0700)
In sbc_check_prot(), if PROTECT is non-zero for a backend device with
DIF disabled, and sess_prot_type is not set go ahead and return
INVALID_CDB_FIELD.

Reviewed-by: Martin Petersen <martin.petersen@oracle.com>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_sbc.c

index 0064ffe..7006c95 100644 (file)
@@ -702,9 +702,13 @@ sbc_check_prot(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb,
                        pi_prot_type = cmd->se_sess->sess_prot_type;
                        break;
                }
+               if (!protect)
+                       return TCM_NO_SENSE;
                /* Fallthrough */
        default:
-               return TCM_NO_SENSE;
+               pr_err("Unable to determine pi_prot_type for CDB: 0x%02x "
+                      "PROTECT: 0x%02x\n", cdb[0], protect);
+               return TCM_INVALID_CDB_FIELD;
        }
 
        if (sbc_set_prot_op_checks(protect, fabric_prot, pi_prot_type, is_write, cmd))