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