security.rst 5.5 KB

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