[PATCH] Check protect info for WRITE10/12/16

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tomo, List

Please find attached a patch that adds checking of the protect field
for WRITE10/12/16 opcodes
and returns a proper sense for non-zero protect fields (we do not
support protect information).
The patch also fixes READ10/12/16 that previously returned the wrong
sense code for this.

Patch commit message contains pointers and extracts from the SBC
standard where this behaviour is discussed/defined.


regards
ronnie sahlberg

Attachment: 0001-PROTECTION-Fail-WRITE10-12-16-with-wprotect-0-with-s.patch.gz
Description: GNU Zip compressed data

From 82366441826fb6f8dc72f2e1d94a7ea02ee6610e Mon Sep 17 00:00:00 2001
From: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx>
Date: Sun, 5 Feb 2012 07:22:29 +1100
Subject: [PATCH] PROTECTION: Fail WRITE10/12/16 with wprotect!=0 with sense code

In SBC 4.21 Protection information model
WRITE10/12/16 are listed as medium access commands.

4.21.2.2 Type 0 protection
Indicates that all such commands should fail if protect bits are !=0
when the device is formatted with type 0 protection (==no protection)

      If type 0 protection is enabled and the RDPROTECT field, WRPROTECT field,
      VRPROTECT field, or ORPROTECT field is set to a non-zero value, then
      medium access commands are invalid and may be terminated by the device
      server with CHECK CONDITION status with the sense key set to ILLEGAL
      REQUEST and the additional sense code set to INVALID FIELD IN CDB

TGTD does not support protection information so we must fail these commands

Also update sbc_rw.c to send the right asc for protection errors for
READ10/12/16

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx>
---
 usr/sbc.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/usr/sbc.c b/usr/sbc.c
index 24aaddb..cf37b3a 100644
--- a/usr/sbc.c
+++ b/usr/sbc.c
@@ -164,9 +164,13 @@ static int sbc_rw(int host_no, struct scsi_cmd *cmd)
 	case READ_10:
 	case READ_12:
 	case READ_16:
+	case WRITE_10:
+	case WRITE_12:
+	case WRITE_16:
+		/* We only support protection information type 0 */
 		if (cmd->scb[1] & 0xe0) {
 			key = ILLEGAL_REQUEST;
-			asc = ASC_INVALID_OP_CODE;
+			asc = ASC_INVALID_FIELD_IN_CDB;
 			goto sense;
 		}
 		break;
@@ -292,9 +296,7 @@ static int sbc_verify(int host_no, struct scsi_cmd *cmd)
 
 	vprotect = cmd->scb[1] & 0xe0;
 	if (vprotect) {
-		/* we dont support formatting with protection information,
-		 * so all verify with vprotect!=0 is an error condition
-		 */
+		/* We only support protection information type 0 */
 		key = ILLEGAL_REQUEST;
 		asc = ASC_INVALID_FIELD_IN_CDB;
 		goto sense;
-- 
1.7.3.1


[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux