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