1NDCTL-SANITIZE-DIMM(1)           ndctl Manual           NDCTL-SANITIZE-DIMM(1)
2
3
4

NAME

6       ndctl-sanitize-dimm - Perform a cryptographic destruction or overwrite
7       of the contents of the given NVDIMM(s)
8

SYNOPSIS

10       ndctl sanitize-dimm <nmem0> [<nmem1>..<nmemN>] [<options>]
11

DESCRIPTION

13       The sanitize-dimm command performs a cryptographic destruction of the
14       contents of the given NVDIMM. It scrambles the data, and any metadata
15       or info-blocks, but it doesn’t modify namespace labels. Therefore, any
16       namespaces on regions associated with the given NVDIMM will be
17       retained, but they will end up in the raw mode.
18
19       Additionally, after completion of this command, the security and
20       passphrase for the given NVDIMM will be disabled, and the passphrase
21       and any key material will also be removed from the keyring and the
22       ndctl keys directory at /etc/ndctl/keys
23
24       The command supports two different methods of performing the
25       cryptographic erase. The default is crypto-erase, but additionally, an
26       overwrite option is available which overwrites not only the data area,
27       but also the label area, thus losing record of any namespaces the given
28       NVDIMM participates in.
29

OPTIONS

31       <dimm>
32           A nmemX device name, or a dimm id number. Restrict the operation to
33           the specified dimm(s). The keyword all can be specified to indicate
34           the lack of any restriction, however this is the same as not
35           supplying a --dimm option at all.
36
37       -b, --bus=
38           A bus id number, or a provider string (e.g. "ACPI.NFIT"). Restrict
39           the operation to the specified bus(es). The keyword all can be
40           specified to indicate the lack of any restriction, however this is
41           the same as not supplying a --bus option at all.
42
43       -c, --crypto-erase
44           Replace the media encryption key on the NVDIMM causing all existing
45           data to read as cipher text with the new key. This does not change
46           label data. Namespaces get reverted to raw mode.
47
48       -o, --ovewrite
49           Wipe the entire DIMM, including label data. This can take
50           significant time, and the command is non-blocking. With this
51           option, the overwrite request is merely submitted to the NVDIMM,
52           and the completion is asynchronous. Depending on the medium and
53           capacity, overwrite may take tens of minutes to many hours.
54
55       -m, --master-passphrase
56           Indicate that we are using the master passphrase to perform the
57           erase. This only is applicable to the crypto-erase option.
58
59       -z, --zero-key
60           Passing in a key with payload that is just 0’s.
61
62       --verbose
63           Emit debug messages.
64

THEORY OF OPERATION

66       The Intel Device Specific Methods (DSM) specification v1.7 and v1.8 [1]
67       introduced the following security management operations: enable
68       passhprase, update passphrase, unlock DIMM, disable security, freeze
69       security, secure (crypto) erase, overwrite, master passphrase enable,
70       master passphrase update, and master passphrase secure erase.
71
72       The security management for NVDIMMs is comprised of two parts. The
73       front end uses the Linux key management framework (trusted and
74       encrypted keys [2]) to store the encrypted passphrases in the
75       kernel-managed keyring. The interface for this is the keyutils utility
76       which uses the key management APIs in the Linux kernel. The back end
77       takes the decrypted payload (which is the DIMM passphrase) and passes
78       it to the DIMM.
79
80       Unlike other DSMs which are composed by libndctl and sent to the kernel
81       via an ioctl, the security DSMs are managed through the security sysfs
82       attribute under the dimm device. A key-ID is written to the security
83       attribute and the kernel pulls the associated key material from the
84       user keyring that is maintained by the kernel.
85
86       The security process begins with the generation of a master key that is
87       used to seal (encrypt) the passphrase for the DIMM. There can either be
88       one common master key that is used to encrypt every DIMM’s passphrase,
89       or a separate key can be generated for each DIMM. The master key is
90       also referred to as the key-encryption-key (kek). The kek can either be
91       generated by the TPM (Trusted Platform Module) on the system, or
92       alternatively, the System Master Key can also be used as the kek
93
94       For testing purposes a user key with randomized payload can also be
95       used as a kek. See [2] for details. To perform any security operations,
96       it is expected that the kek has been added to the kernel’s user keyring
97       as shown in example below:
98
99           # keyctl show
100           Session Keyring
101            736023423 --alswrv      0     0  keyring: _ses
102            675104189 --alswrv      0 65534   \_ keyring: _uid.0
103            680187394 --alswrv      0     0       \_ trusted: nvdimm-master
104
105       Before performing any of the security operations, all the regions
106       associated with the DIMM in question need to be disabled. For the
107       overwrite operation, in addition to the regions, the dimm also needs to
108       be disabled.
109
110       [1] <http://pmem.io/documents/NVDIMM_DSM_Interface-V1.8.pdf>
111       [2] <https://www.kernel.org/doc/Documentation/security/keys/
112       trusted-encrypted.rst>
113
114       The following sub-sections describe specifics of each security feature.
115
116   UNLOCK
117       Unlock  is  performed  by  the  kernel, however a preparation step must
118       happen before the unlock DSM  can  be  issued  by  the  kernel.  It  is
119       expected  that from the initramfs, a setup command (ndctl load-keys) is
120       executed before the  libnvdimm  module  is  loaded  by  modprobe.  This
121       command  will  inject  the  kek  and the encrypted passphrases into the
122       kernel’s user keyring. During the probe of  the  libnvdimm  driver,  it
123       will:
124
125         1. Check  the  security  state  of  the device and see if the DIMM is
126           locked
127
128        2. Request the associated encrypted passphrase from the kernel’s  user
129           key ring
130
131        3. Use the kek to decrypt the passphrase
132
133        4. Create the unlock DSM, copy the decrypted payload into the DSM
134
135        5. Issue the DSM to unlock the DIMM
136
137       If  the DIMM is already unlocked, the kernel will attempt to revalidate
138       the passphrase. If we fail to revalidate  the  passphrase,  the  kernel
139       will   freeze   the   security   and   disallow  any  further  security
140       configuration changes.  A  kernel  module  parameter  is  available  to
141       override this behavior.
142
143   SETUP USER PASSPHRASE
144       To  setup  the passphrase for a DIMM, it is expected that the kek to be
145       used is present in the kernel’s user keyring. The kek encrypts the DIMM
146       passphrase  using  the  enc32  key  format. The plaintext passphrase is
147       never provided by or made visible to the user. It is  instead  randomly
148       generated  by the kernel and userspace does not have access to it. Upon
149       encryption,  a  binary  blob  of  the  passphrase  is  written  to  the
150       passphrase  blob  storage  directory  (/etc/ndctl/keys).  The  user  is
151       responsible for backing up the passphrase blobs to a secure location.
152
153   UPDATE USER PASSPHRASE
154       The update user passphrase operation  uses  the  same  DSM  command  as
155       enable  user passphrase. Most of the work is done on the key management
156       side. The user has the option of  providing  a  new  kek  for  the  new
157       passphrase,  but continuing to use the existing kek is also acceptable.
158       The following operations are performed for update-passphrase:
159
160        1. Remove the encrypted passphrase from the kernel’s user keyring.
161
162        2. Rename the passphrase blob to old.
163
164        3. Load this old passphrase blob into the keyring with an "old" name.
165
166        4. Create the new passphrase and encrypt with the  kek.
167
168        5. Send DSM with the old and new decrypted passphrases.
169
170        6. Remove old passphrase and the passphrase blob from the keyring.
171
172   REMOVE USER PASSPHRASE
173       The key-ID for the passphrase to be removed is written  to  sysfs.  The
174       kernel  then  sends  the DSM to disable security, and the passphrase is
175       then removed from the keyring, and the associated  passphrase  blob  is
176       deleted.
177
178   CRYPTO (SECURE) ERASE
179       This  operation  is  similar  to remove-passphrase. The kernel issues a
180       WBINVD instruction before and after the operation  to  ensure  no  data
181       corruption  from  a  stale CPU cache. Use ndctl’s sanitize-dimm command
182       with the --crypto-erase option to perform this operation.
183
184   OVERWRITE
185       This is invoked using --overwrite option for ndctl  sanitize-dimm.  The
186       overwrite  operation  wipes the entire NVDIMM. The operation can take a
187       significant  amount  of  time.   NOTE:   When   the   command   returns
188       successfully,  it  just  means overwrite has been successfully started,
189       and  not  that  the  overwrite  is   complete.   Subsequently,   'ndctl
190       wait-overwrite’can  be used to wait for the NVDIMMs that are performing
191       overwrite. Upon successful  completion  of  an  overwrite,  the  WBINVD
192       instruction  is  issued  by  the  kernel.  If  both  --crypto-erase and
193       --overwrite options are supplied, then crypto-erase is performed before
194       overwrite.
195
196   SECURITY FREEZE
197       This  operation  does  not  require  a  passphrase. This will cause any
198       security command other than a status query to be locked out  until  the
199       next boot.
200
201   MASTER PASSPHRASE SETUP, UPDATE, and CRYPTO ERASE
202       These  operations are similar to the user passphrase enable and update.
203       The only difference is that a different passphrase is used. The  master
204       passphrase  has  no  relation to the master key (kek) which is used for
205       encryption of either passphrase.
206
208       Copyright (c) 2016 - 2019, Intel Corporation. License  GPLv2:  GNU  GPL
209       version  2  <http://gnu.org/licenses/gpl.html>.  This is free software:
210       you are free to change and redistribute it. There is  NO  WARRANTY,  to
211       the extent permitted by law.
212

SEE ALSO

214       ndctl-wait-overwrite(1), <https://trustedcomputinggroup.org/wp-content/
215       uploads/TCG_SWG_SIIS_Version_1_07_Revision_1_00.pdf>
216
217
218
219ndctl                             2019-10-28            NDCTL-SANITIZE-DIMM(1)
Impressum