diff options
-rw-r--r-- | drivers/target/target_core_sbc.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index ee0cb9d96929..8a462773d0c8 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c | |||
@@ -38,11 +38,27 @@ static sense_reason_t | |||
38 | sbc_emulate_readcapacity(struct se_cmd *cmd) | 38 | sbc_emulate_readcapacity(struct se_cmd *cmd) |
39 | { | 39 | { |
40 | struct se_device *dev = cmd->se_dev; | 40 | struct se_device *dev = cmd->se_dev; |
41 | unsigned char *cdb = cmd->t_task_cdb; | ||
41 | unsigned long long blocks_long = dev->transport->get_blocks(dev); | 42 | unsigned long long blocks_long = dev->transport->get_blocks(dev); |
42 | unsigned char *rbuf; | 43 | unsigned char *rbuf; |
43 | unsigned char buf[8]; | 44 | unsigned char buf[8]; |
44 | u32 blocks; | 45 | u32 blocks; |
45 | 46 | ||
47 | /* | ||
48 | * SBC-2 says: | ||
49 | * If the PMI bit is set to zero and the LOGICAL BLOCK | ||
50 | * ADDRESS field is not set to zero, the device server shall | ||
51 | * terminate the command with CHECK CONDITION status with | ||
52 | * the sense key set to ILLEGAL REQUEST and the additional | ||
53 | * sense code set to INVALID FIELD IN CDB. | ||
54 | * | ||
55 | * In SBC-3, these fields are obsolete, but some SCSI | ||
56 | * compliance tests actually check this, so we might as well | ||
57 | * follow SBC-2. | ||
58 | */ | ||
59 | if (!(cdb[8] & 1) && !!(cdb[2] | cdb[3] | cdb[4] | cdb[5])) | ||
60 | return TCM_INVALID_CDB_FIELD; | ||
61 | |||
46 | if (blocks_long >= 0x00000000ffffffff) | 62 | if (blocks_long >= 0x00000000ffffffff) |
47 | blocks = 0xffffffff; | 63 | blocks = 0xffffffff; |
48 | else | 64 | else |