stenc icon indicating copy to clipboard operation
stenc copied to clipboard

stenc + CentOS 7.3, 7.4 and 7.5: Sense Code: Illegal Request (0x05) on LTO drive (encryption)

Open devnullzero opened this issue 8 years ago • 7 comments

Under CentOS 7.3 to 7.5 stenc returns the following error:

$ stenc -f /dev/nst0 -a 1 -e on -k test.key Provided key length is 256 bits. Key checksum is 7a43. Turning on encryption on device '/dev/nst0'... Sense Code: Illegal Request (0x05) ASC: 0x26 ASCQ: 0x00 Additional data: 0x00000000000000000000000000000000 Error: Turning encryption on for '/dev/nst0' failed! Usage: stenc --version | -g -k [-kd ] | -f [--detail] [-e <on/mixed/rawread/off> [-k ] [-kd ] [-a ] [--protect | --unprotect] [--ckod] ] Type 'man stenc' for more information.

Adding the line: memset(&kad,0,sizeof(kad)); in scsiencrypt.cpp fix this issue as described here:

What could cause a 'sense error' when setting LTO encryption? https://serverfault.com/questions/864580/what-could-cause-a-sense-error-when-setting-lto-encryption

Patch for stenc v1.0.7 (https://github.com/scsitape/stenc/archive/1.0.7.tar.gz):

--- src/scsiencrypt.cpp	2018-08-29 03:48:57.815019821 +0000
+++ src/scsiencrypt.fixed.cpp	2018-08-29 03:49:36.303018034 +0000
@@ -250,6 +250,7 @@
 	//create the key descriptor
 	if(eOptions->keyName!=""){
 		SSP_KAD kad;
+		memset(&kad,0,sizeof(kad));
 		kad.type=0x00;
 		kad.authenticated=0;
 		//set the descriptor length to the length of the keyName

Patch: scsiencrypt.cpp.patch.txt

Thanks to lan and Kasperd for the solution.

devnullzero avatar Aug 26 '18 18:08 devnullzero

solves the issue on Debian8 with Quantium LTO6 drive too. thanks a lot!

remcohn avatar Sep 06 '18 17:09 remcohn

Attempting to enable encryption on an IBM tape library 3573-TL from a machine running CenOS 7.4 and receive an identical error even after applying the patch.

# stenc -f /dev/nst0 -a 1 -e on -k /etc/tape.key Provided key length is 256 bits. Key checksum is 4637. Turning on encryption on device '/dev/nst0'... Sense Code: Illegal Request (0x05) ASC: 0x24 ASCQ: 0x00 Additional data: 0x00000001534c4f5430303000000007c7e1000000000080b560000000000000000000000000000000000000000000000000000000000000000000000000000000000000003039355133303439363600000000000000000000 Error: Turning encryption on for '/dev/nst0' failed!

bahelit avatar Oct 23 '18 15:10 bahelit

@ninthclowd what do you think, should we merge this?

jonasstein avatar Apr 16 '19 08:04 jonasstein

@bahelit Your error is different. ASC 0x24 means your drive rejects one of the SCSI commands it got from stenc. The original error referred to ASC 0x26 which means the SCSI command was accepted but the data sent by that command wasn't.

scsirob avatar Sep 17 '19 19:09 scsirob

We also need the patch on Debian 10 amd64. Our tape drive is Quantum Ultrium LTO-5.

Please merge the patch. I think there can be nothing wrong with zeroing the memory before using it...

hrubsa avatar Sep 19 '19 08:09 hrubsa

When you zero the entire kad structure, the two lines below it to set kad.type and kad.authenticated to zero can be removed.

scsirob avatar May 28 '20 16:05 scsirob

Adding the line: memset(&kad,0,sizeof(kad)); in scsiencrypt.cpp fix this issue as described here:

What could cause a 'sense error' when setting LTO encryption? https://serverfault.com/questions/864580/what-could-cause-a-sense-error-when-setting-lto-encryption

Patch for stenc v1.0.7 (https://github.com/scsitape/stenc/archive/1.0.7.tar.gz):

Just tested on Debian 9 and 10 with Quantum LTO5. Patch works perfectly.

royalmoose avatar Jun 06 '20 13:06 royalmoose