1NDCTL-SETUP-PASSPHRASE(1)        ndctl Manual        NDCTL-SETUP-PASSPHRASE(1)
2
3
4

NAME

6       ndctl-setup-passphrase - setup and enable the security passphrase for
7       an NVDIMM
8

SYNOPSIS

10       ndctl setup-passphrase <nmem0> [<nmem1>..<nmemN>] -k <key_handle> [<options>]
11

DESCRIPTION

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: <https://
18       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

OPTIONS

27       <dimm>
28
29               A 'nmemX' device name, or a dimm id number. The keyword 'all' can
30               be specified to carry out the operation on every dimm in the system,
31               optionally filtered by bus id (see --bus= option).
32
33       -b, --bus=
34           Enforce  that  the  operation  only  be carried on devices that are
35           attached to the given bus. Where bus can be a provider  name  or  a
36           bus id number.
37
38       -k, --key_handle=
39           Handle  for  the  master kek (key-encryption-key) that will be used
40           for sealing the passphrase(s) for the given DIMM(s). The format is:
41           <key type>:<key description>
42             e.g. trusted:nvdimm-master
43           NOTE:  The  kek  is  expected  to  have  been  loaded into the user
44           keyring.
45
46       -m, --master-passphrase
47           Indicates that we are managing the master passphrase instead of the
48           user passphrase.
49
50       -v, --verbose
51           Emit debug messages.
52

THEORY OF OPERATION

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

SEE ALSO:

202       ndctl-update-passphrase(1), ndctl-remove-passphrase(1)
203
204
205
206ndctl                             2019-05-10         NDCTL-SETUP-PASSPHRASE(1)
Impressum