blob: 4c36c05ca98eb8803c448dcbeff2e38758f64ce5 [file] [log] [blame]
Dave Jiang1f4883f2018-12-10 13:36:14 -07001NVDIMM SECURITY
2===============
3
41. Introduction
5---------------
6
7With the introduction of Intel Device Specific Methods (DSM) v1.8
8specification [1], security DSMs are introduced. The spec added the following
9security DSMs: "get security state", "set passphrase", "disable passphrase",
10"unlock unit", "freeze lock", "secure erase", and "overwrite". A security_ops
11data structure has been added to struct dimm in order to support the security
12operations and generic APIs are exposed to allow vendor neutral operations.
13
142. Sysfs Interface
15------------------
16The "security" sysfs attribute is provided in the nvdimm sysfs directory. For
17example:
18/sys/devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0012:00/ndbus0/nmem0/security
19
20The "show" attribute of that attribute will display the security state for
21that DIMM. The following states are available: disabled, unlocked, locked,
22frozen, and overwrite. If security is not supported, the sysfs attribute
23will not be visible.
24
25The "store" attribute takes several commands when it is being written to
26in order to support some of the security functionalities:
27update <old_keyid> <new_keyid> - enable or update passphrase.
28disable <keyid> - disable enabled security and remove key.
29freeze - freeze changing of security states.
30erase <keyid> - delete existing user encryption key.
31overwrite <keyid> - wipe the entire nvdimm.
32master_update <keyid> <new_keyid> - enable or update master passphrase.
33master_erase <keyid> - delete existing user encryption key.
34
353. Key Management
36-----------------
37
38The key is associated to the payload by the DIMM id. For example:
39# cat /sys/devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0012:00/ndbus0/nmem0/nfit/id
408089-a2-1740-00000133
41The DIMM id would be provided along with the key payload (passphrase) to
42the kernel.
43
44The security keys are managed on the basis of a single key per DIMM. The
45key "passphrase" is expected to be 32bytes long. This is similar to the ATA
46security specification [2]. A key is initially acquired via the request_key()
47kernel API call during nvdimm unlock. It is up to the user to make sure that
48all the keys are in the kernel user keyring for unlock.
49
50A nvdimm encrypted-key of format enc32 has the description format of:
51nvdimm:<bus-provider-specific-unique-id>
52
53See file ``Documentation/security/keys/trusted-encrypted.rst`` for creating
54encrypted-keys of enc32 format. TPM usage with a master trusted key is
55preferred for sealing the encrypted-keys.
56
574. Unlocking
58------------
59When the DIMMs are being enumerated by the kernel, the kernel will attempt to
60retrieve the key from the kernel user keyring. This is the only time
61a locked DIMM can be unlocked. Once unlocked, the DIMM will remain unlocked
62until reboot. Typically an entity (i.e. shell script) will inject all the
63relevant encrypted-keys into the kernel user keyring during the initramfs phase.
64This provides the unlock function access to all the related keys that contain
65the passphrase for the respective nvdimms. It is also recommended that the
66keys are injected before libnvdimm is loaded by modprobe.
67
685. Update
69---------
70When doing an update, it is expected that the existing key is removed from
71the kernel user keyring and reinjected as different (old) key. It's irrelevant
72what the key description is for the old key since we are only interested in the
73keyid when doing the update operation. It is also expected that the new key
74is injected with the description format described from earlier in this
75document. The update command written to the sysfs attribute will be with
76the format:
77update <old keyid> <new keyid>
78
79If there is no old keyid due to a security enabling, then a 0 should be
80passed in.
81
826. Freeze
83---------
84The freeze operation does not require any keys. The security config can be
85frozen by a user with root privelege.
86
877. Disable
88----------
89The security disable command format is:
90disable <keyid>
91
92An key with the current passphrase payload that is tied to the nvdimm should be
93in the kernel user keyring.
94
958. Secure Erase
96---------------
97The command format for doing a secure erase is:
98erase <keyid>
99
100An key with the current passphrase payload that is tied to the nvdimm should be
101in the kernel user keyring.
102
1039. Overwrite
104------------
105The command format for doing an overwrite is:
106overwrite <keyid>
107
108Overwrite can be done without a key if security is not enabled. A key serial
109of 0 can be passed in to indicate no key.
110
111The sysfs attribute "security" can be polled to wait on overwrite completion.
112Overwrite can last tens of minutes or more depending on nvdimm size.
113
114An encrypted-key with the current user passphrase that is tied to the nvdimm
115should be injected and its keyid should be passed in via sysfs.
116
11710. Master Update
118-----------------
119The command format for doing a master update is:
120update <old keyid> <new keyid>
121
122The operating mechanism for master update is identical to update except the
123master passphrase key is passed to the kernel. The master passphrase key
124is just another encrypted-key.
125
126This command is only available when security is disabled.
127
12811. Master Erase
129----------------
130The command format for doing a master erase is:
131master_erase <current keyid>
132
133This command has the same operating mechanism as erase except the master
134passphrase key is passed to the kernel. The master passphrase key is just
135another encrypted-key.
136
137This command is only available when the master security is enabled, indicated
138by the extended security status.
139
140[1]: http://pmem.io/documents/NVDIMM_DSM_Interface-V1.8.pdf
141[2]: http://www.t13.org/documents/UploadedDocuments/docs2006/e05179r4-ACS-SecurityClarifications.pdf