jethrogb / lenovo-password

Implementation of Lenovo ThinkPad HDD password algorithm
Other
121 stars 27 forks source link

Readme does not work with nvme drives #2

Open attila123 opened 6 years ago

attila123 commented 6 years ago

Hi, I got a new Lenovo T470 laptop in my workplace, which apparently has an nvme SSD (which I did not even know existed). I wondered what the HDD1 password BIOS setting was, so I got to your website and to this project. I wanted to try the first command in the readme, but that gives an error:

$ sudo hdparm --Istdout /dev/nvme0n1 > nvme0n1.ata_identify
 HDIO_DRIVE_CMD(identify) failed: Inappropriate ioctl for device

My hdparm is from Arch repo, and is the latest version (v9.56). I wonder if this command could be somehow substituted with the nvme command in case of these nvme drives (see https://wiki.archlinux.org/index.php/Solid_State_Drive/NVMe). Now I found a post which seems to support that: https://forum.manjaro.org/t/hdparm-not-getting-info-for-ssd-samsung-960-evo-m-2/35445/2 "hdparm expects IDE, libata and SCSI-ATA devices. NVMe is not any of those. If you want to get info about your NVMe device, install the nvme-cli tools." I tried the above hdparm command on a sda device and it spits out some hexadecimal data. I installed nvme-cli from AUR, but I wonder if there is a command which would produce the same (or similar, but usable) output, and whether this project can work with nvme drives in the first place. If not, maybe it should be clarified in the readme. Thanks.

jethrogb commented 6 years ago

I think you might be able to use the nvme id-ctrl and ncme security-send commands.

I also wrote this utility, but it doesn't quite implement the Lenovo algorithm so you'd need to make some changes (in read_password_err): https://github.com/jethrogb/nvme-ata-security/tree/master/user

attila123 commented 6 years ago

Thanks for the reply! :) Just for the record:

$ sudo nvme id-ctrl /dev/nvme0n1 --human-readable --vendor-specific
NVME Identify Controller:
vid     : 0x8086
ssvid   : 0x8086
sn      : BTHH81450TNS512D    
mn      : INTEL SSDPEKKF512G8L                    
fr      : L05P    
rab     : 6
ieee    : 5cd2e4
cmic    : 0
  [2:2] : 0 PCI
  [1:1] : 0 Single Controller
  [0:0] : 0 Single Port

mdts    : 6
cntlid  : 1
ver     : 10300
rtd3r   : 7a120
rtd3e   : 1e8480
oaes    : 0x200
 [31:9] : 0x1   Reserved
  [8:8] : 0 Namespace Attribute Changed Event Not Supported

ctratt  : 0
  [0:0] : 0 128-bit Host Identifier Not Supported

oacs    : 0x17
  [8:8] : 0 Doorbell Buffer Config Not Supported
  [7:7] : 0 Virtualization Management Not Supported
  [6:6] : 0 NVMe-MI Send and Receive Not Supported
  [5:5] : 0 Directives Not Supported
  [4:4] : 0x1   Device Self-test Supported
  [3:3] : 0 NS Management and Attachment Not Supported
  [2:2] : 0x1   FW Commit and Download Supported
  [1:1] : 0x1   Format NVM Supported
  [0:0] : 0x1   Security Send and Receive Supported

acl     : 4
aerl    : 7
frmw    : 0x14
  [4:4] : 0x1   Firmware Activate Without Reset Supported
  [3:1] : 0x2   Number of Firmware Slots
  [0:0] : 0 Firmware Slot 1 Read/Write

lpa     : 0xf
  [7:3] : 0x1   Reserved
  [2:2] : 0x1   Extended data for Get Log Page Supported
  [1:1] : 0x1   Command Effects Log Page Supported
  [0:0] : 0x1   SMART/Health Log Page per NS Supported

elpe    : 255
npss    : 4
avscc   : 0
  [0:0] : 0 Admin Vendor Specific Commands uses Vendor Specific Format

apsta   : 0x1
  [0:0] : 0x1   Autonomous Power State Transitions Supported

wctemp  : 348
cctemp  : 353
mtfa    : 50
hmpre   : 0
hmmin   : 0
tnvmcap : 0
unvmcap : 0
rpmbs   : 0
 [31:24]: 0 Access Size
 [23:16]: 0 Total Size
  [5:3] : 0 Authentication Method
  [2:0] : 0 Number of RPMB Units

edstt   : 5
dsto    : 1
fwug    : 0
kas     : 0
hctma   : 0x1
  [0:0] : 0x1   Host Controlled Thermal Management Supported

mntmt   : 303
mxtmt   : 350
sanicap : 0
  [2:2] : 0 Overwrite Sanitize Operation Not Supported
  [1:1] : 0 Block Erase Sanitize Operation Not Supported
  [0:0] : 0 Crypto Erase Sanitize Operation Not Supported

hmminds : 0
hmmaxd  : 0
sqes    : 0x66
  [7:4] : 0x6   Max SQ Entry Size (64)
  [3:0] : 0x6   Min SQ Entry Size (64)

cqes    : 0x44
  [7:4] : 0x4   Max CQ Entry Size (16)
  [3:0] : 0x4   Min CQ Entry Size (16)

maxcmd  : 0
nn      : 1
oncs    : 0x5f
  [6:6] : 0x1   Timestamp Supported
  [5:5] : 0 Reservations Not Supported
  [4:4] : 0x1   Save and Select Supported
  [3:3] : 0x1   Write Zeroes Supported
  [2:2] : 0x1   Data Set Management Supported
  [1:1] : 0x1   Write Uncorrectable Supported
  [0:0] : 0x1   Compare Supported

fuses   : 0
  [0:0] : 0 Fused Compare and Write Not Supported

fna     : 0
  [2:2] : 0 Crypto Erase Not Supported as part of Secure Erase
  [1:1] : 0 Crypto Erase Applies to Single Namespace(s)
  [0:0] : 0 Format Applies to Single Namespace(s)

vwc     : 0x1
  [0:0] : 0x1   Volatile Write Cache Present

awun    : 0
awupf   : 0
nvscc   : 0
  [0:0] : 0 NVM Vendor Specific Commands uses Vendor Specific Format

acwu    : 0
sgls    : 0
 [1:0]  : 0 Scatter-Gather Lists Not Supported

subnqn  : 
ioccsz  : 0
iorcsz  : 0
icdoff  : 0
ctrattr : 0
  [0:0] : 0 Dynamic Controller Model

msdbd   : 0
ps    0 : mp:9.00W operational enlat:0 exlat:0 rrt:0 rrl:0
          rwt:0 rwl:0 idle_power:- active_power:-
ps    1 : mp:4.60W operational enlat:0 exlat:0 rrt:1 rrl:1
          rwt:1 rwl:1 idle_power:- active_power:-
ps    2 : mp:3.80W operational enlat:0 exlat:0 rrt:2 rrl:2
          rwt:2 rwl:2 idle_power:- active_power:-
ps    3 : mp:0.0450W non-operational enlat:2000 exlat:2000 rrt:3 rrl:3
          rwt:3 rwl:3 idle_power:- active_power:-
ps    4 : mp:0.0040W non-operational enlat:6000 exlat:8000 rrt:4 rrl:4
          rwt:4 rwl:4 idle_power:- active_power:-
vs[]:
       0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
00a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
00b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
00c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 "................"
00d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
00e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
00f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
01a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
01b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
01c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
01d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
01e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
01f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0220: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0230: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0240: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0250: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0260: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0270: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0290: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
02a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
02b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
02c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
02d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
02e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
02f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0310: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0340: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0350: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0360: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0370: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
0390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
03a0: 0f 02 2d 30 56 4f 41 2e cd 55 00 00 00 00 00 00 "..-0VOA..U......"
03b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
03c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
03d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
03e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
03f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"

nvme security-send without any specific options:

$ sudo nvme security-send /dev/nvme0n1
no firmware file provided

I don't understand what it does, so I stop experimenting. :)

I will need a backup solution anyway... Working on that...

rvanlaar commented 5 years ago

I've tried to use the lenovo password algorithm with the nvme program. https://github.com/jethrogb/nvme-ata-security/tree/master/user

It didn't work. Either they changed the algorithm or something else doesn't work.