Skip to contentSkip to conversation

target: do not overwrite CDB byte 1

PATCH Applied Bodo Stroesser 4 participants 4 messages Oct 14, 2019 – Oct 18, 2019 SCSI target

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target: do not overwrite CDB byte 1

passthrough_parse_cdb() - used by TCMU and PSCSI - attepts to reset the LUN field of SCSI-2 CDBs (bits 5,6,7 of byte 1). The current code is wrong, as for newer commands not having the LUN field it overwrites relevant command bits (e.g. for SECURITY PROTOCOL IN / OUT)
We think this code was unnecessary from the beginning or at least it is no longer useful. So we remove it entirely.

---
  drivers/target/target_core_device.c |   21 ---------------------
  1 file changed, 21 deletions(-)
drivers/target/target_core_device.c +0 -21
@@ -1075,27 +1075,6 @@ passthrough_parse_cdb(struct se_cmd *cmd
  	unsigned int size;
   	/*
-	 * Clear a lun set in the cdb if the initiator talking to use spoke
-	 * and old standards version, as we can't assume the underlying device
-	 * won't choke up on it.
-	 */
-	switch (cdb[0]) {
-	case READ_10: /* SBC - RDProtect */
-	case READ_12: /* SBC - RDProtect */
-	case READ_16: /* SBC - RDProtect */
-	case SEND_DIAGNOSTIC: /* SPC - SELF-TEST Code */
-	case VERIFY: /* SBC - VRProtect */
-	case VERIFY_16: /* SBC - VRProtect */
-	case WRITE_VERIFY: /* SBC - VRProtect */
-	case WRITE_VERIFY_12: /* SBC - VRProtect */
-	case MAINTENANCE_IN: /* SPC - Parameter Data Format for SA RTPG */
-		break;
-	default:
-		cdb[1] &= 0x1f; /* clear logical unit number */
-		break;
-	}
-
-	/*
  	 * For REPORT LUNS we always need to emulate the response, for everything
  	 * else, pass it up.
  	 */
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Bodo Stroesser

passthrough_parse_cdb() - used by TCMU and PSCSI - attepts to reset the LUN field of SCSI-2 CDBs (bits 5,6,7 of byte 1). The current code is wrong, as for newer commands not having the LUN field it overwrites relevant command bits (e.g. for SECURITY PROTOCOL IN / OUT)
We think this code was unnecessary from the beginning or at least it is no longer useful. So we remove it entirely.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Bodo Stroesser
Quoted 8 lines · Bodo Stroesser

passthrough_parse_cdb() - used by TCMU and PSCSI - attepts to reset the LUN field of SCSI-2 CDBs (bits 5,6,7 of byte 1). The current code is wrong, as for newer commands not having the LUN field it overwrites relevant command bits (e.g. for SECURITY PROTOCOL IN / OUT)
We think this code was unnecessary from the beginning or at least it is no longer useful. So we remove it entirely.

Quoted 5 lines

---
 drivers/target/target_core_device.c |   21 ---------------------

 1 file changed, 21 deletions(-)

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke		      Teamlead Storage & Networking
[email protected]			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 247165 (AG München), GF: Felix Imendörffer
#3 lore raw
In reply to Bodo Stroesser

Bodo,

Quoted 6 lines

passthrough_parse_cdb() - used by TCMU and PSCSI - attepts to reset the LUN field of SCSI-2 CDBs (bits 5,6,7 of byte 1). The current code is wrong, as for newer commands not having the LUN field it overwrites relevant command bits (e.g. for SECURITY PROTOCOL IN / OUT) We think this code was unnecessary from the beginning or at least it is no longer useful. So we remove it entirely.

Applied to 5.4/scsi-fixes, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering