NDCTL-SETUP-PASSPHRASE(1)
๐ NDCTL-SETUP-PASSPHRASE ๐ (from the ndctl manual)
okay so bestie, welcome to the glow-up zone where we set up and enable a security passphrase for an NVDIMM โจ this is the ndctl-setup-passphrase page and yes it's a whole vibe, let's get into it ๐ซถ
๐ธ NAME ๐ธ
ndctl-setup-passphrase โ setup and enable the security passphrase for an NVDIMM ๐โจ
๐ SYNOPSIS ๐
ndctl setup-passphrase <nmem0> [<nmem1>..<nmemN>] -k <key_handle> [<options>]
๐ DESCRIPTION ๐
so the whole point of this command is to setup and enable a security passphrase for one or more NVDIMMs. iconic. but there's a lil prerequisite, no cap:
for this command to actually succeed, it's expected that the master key has previously been loaded into the user keyring. like, beforehand. already done. if you wanna know how to do that, the kernel documentation has you covered right here:
https://www.kernel.org/doc/html/latest/security/keys/trusted-encrypted.html
the passphrase blobs get created in the /etc/ndctl/keys directory ๐ and the file name format is literally this:
nvdimm_<dimm-unique-id>_<hostname>.blob
๐ heads up bestie: the command will fail if the passphrase is already in the user keyring, OR if a passphrase blob already exists in /etc/ndctl/keys. so if it's throwing hands, check those two things first.
โจ OPTIONS โจ
<dimm>โ annmemXdevice name, or a dimm id number. restricts the operation to the specified dimm(s). you can pass the keywordallto say "no restriction whatsoever", but lowkey that's the exact same thing as just not supplying a--dimmoption at all ๐ซ-b,--bus=โ a bus id number, or a provider string (e.g."ACPI.NFIT"). restricts the operation to the specified bus(es). and yep, the keywordallworks here too to mean no restriction, but again that's literally the same as not supplying a--busoption at all ๐ซ-k,--key_handle=โ the handle for the master kek (key-encryption-key) that's gonna be used for sealing the passphrase(s) for the given DIMM(s). the format is<key type>:<key description>, e.g.trusted:nvdimm-master.
NOTE: the kek is expected to have been loaded into the user keyring. don't skip this step bestie, it will Not go well ๐ญ
-m,--master-passphraseโ tells us we're managing the master passphrase instead of the user passphrase ๐-v,--verboseโ emit debug messages. for when you wanna see everything ๐โจ
๐ฎ THEORY OF OPERATION ๐ฎ
okay this is the part where it gets juicy. the Intel Device Specific Methods (DSM) specification v1.7 and v1.8 [1] introduced these security management operations: enable passphrase, update passphrase, unlock DIMM, disable security, freeze security, secure (crypto) erase, overwrite, master passphrase enable, master passphrase update, and master passphrase secure erase. that's a lot of lore, i know.
the security management for NVDIMMs is comprised of two parts, bestie:
- the front end uses the Linux key management framework (trusted and encrypted keys [2]) to store the encrypted passphrases in the kernel-managed keyring. the interface for this is the
keyutilsutility, which uses the key management APIs in the Linux kernel. - the back end takes the decrypted payload (which is the DIMM passphrase) and passes it to the DIMM.
unlike other DSMs which are composed by libndctl and sent to the kernel via an ioctl, the security DSMs are managed through the security sysfs attribute under the dimm device. a key-ID is written to the security attribute and the kernel pulls the associated key material from the user keyring that is maintained by the kernel. slay ๐
the security process begins with the generation of a master key that's used to seal (encrypt) the passphrase for the DIMM. there can either be one common master key used to encrypt every DIMM's passphrase, or a separate key can be generated for each DIMM. the master key is also referred to as the key-encryption-key (kek). the kek can either be generated by the TPM (Trusted Platform Module) on the system, or alternatively, the System Master Key can also be used as the kek.
for testing purposes a user key with randomized payload can also be used as a kek. see [2] for details. to perform any security operations, it's expected that the kek has been added to the kernel's user keyring as shown in the example below:
# keyctl show
Session Keyring
736023423 --alswrv 0 0 keyring: _ses
675104189 --alswrv 0 65534 \_ keyring: _uid.0
680187394 --alswrv 0 0 \_ trusted: nvdimm-master
โ ๏ธ before performing any of the security operations, all the regions associated with the DIMM in question need to be disabled. and for the overwrite operation, in addition to the regions, the dimm also needs to be disabled. don't forget, bestie ๐ซถ
[1] http://pmem.io/documents/NVDIMM_DSM_Interface-V1.8.pdf [2] https://www.kernel.org/doc/Documentation/security/keys/trusted-encrypted.rst
the following sub-sections describe specifics of each security feature ๐
๐ UNLOCK ๐
unlock is performed by the kernel, however a preparation step must happen before the unlock DSM can be issued by the kernel. it's expected that from the initramfs, a setup command (ndctl load-keys) is executed before the libnvdimm module is loaded by modprobe. this command will inject the kek and the encrypted passphrases into the kernel's user keyring. during the probe of the libnvdimm driver, it will:
- check the security state of the device and see if the DIMM is locked
- request the associated encrypted passphrase from the kernel's user key ring
- use the kek to decrypt the passphrase
- create the unlock DSM, copy the decrypted payload into the DSM
- issue the DSM to unlock the DIMM
if the DIMM is already unlocked, the kernel will attempt to revalidate the passphrase. and if we fail to revalidate the passphrase, the kernel will freeze the security and disallow any further security configuration changes ๐ a kernel module parameter is available to override this behavior, so like, there's an escape hatch.
๐ SETUP USER PASSPHRASE ๐
to setup the passphrase for a DIMM, it's expected that the kek to be used is present in the kernel's user keyring. the kek encrypts the DIMM passphrase using the enc32 key format. the plaintext passphrase is never provided by or made visible to the user โ it's instead randomly generated by the kernel and userspace does not have access to it. upon encryption, a binary blob of the passphrase is written to the passphrase blob storage directory (/etc/ndctl/keys).
๐ the user is responsible for backing up the passphrase blobs to a secure location. yes YOU. do it. fr fr.
๐ฆ UPDATE USER PASSPHRASE ๐ฆ
the update user passphrase operation uses the same DSM command as enable user passphrase. most of the work is done on the key management side. the user has the option of providing a new kek for the new passphrase, but continuing to use the existing kek is also acceptable. the following operations are performed for update-passphrase:
- remove the encrypted passphrase from the kernel's user keyring
- rename the passphrase blob to
old - load this old passphrase blob into the keyring with an
"old"name - create the new passphrase and encrypt with the kek
- send DSM with the old and new decrypted passphrases
- remove old passphrase and the passphrase blob from the keyring
๐ง REMOVE USER PASSPHRASE ๐ง
the key-ID for the passphrase to be removed is written to sysfs. the kernel then sends the DSM to disable security, and the passphrase is then removed from the keyring, and the associated passphrase blob is deleted. clean sweep โจ
๐ CRYPTO (SECURE) ERASE ๐
this operation is similar to remove-passphrase. the kernel issues a WBINVD instruction before and after the operation to ensure no data corruption from a stale CPU cache. use ndctl's sanitize-dimm command with the --crypto-erase option to perform this operation. poof, gone ๐ซง
๐ฅ OVERWRITE ๐ฅ
this is invoked using the --overwrite option for ndctl sanitize-dimm. the overwrite operation wipes the entire NVDIMM. the operation can take a significant amount of time โ like, be patient bestie.
NOTE: when the command returns successfully, it just means overwrite has been successfully started, and not that the overwrite is complete. ๐ญ
subsequently, ndctl wait-overwrite can be used to wait for the NVDIMMs that are performing overwrite. upon successful completion of an overwrite, the WBINVD instruction is issued by the kernel. if both --crypto-erase and --overwrite options are supplied, then crypto-erase is performed before overwrite.
๐ง SECURITY FREEZE ๐ง
this operation does not require a passphrase. it will cause any security command other than a status query to be locked out until the next boot. so like, nothing's getting through until you reboot. periodt. ๐
๐ MASTER PASSPHRASE SETUP, UPDATE, and CRYPTO ERASE ๐
these operations are similar to the user passphrase enable and update. the only difference is that a different passphrase is used. the master passphrase has no relation to the master key (kek), which is used for encryption of either passphrase. don't get them confused bestie, they are not the same thing ๐
๐ COPYRIGHT ๐
Copyright ยฉ 2016 - 2022, Intel Corporation. License GPLv2: GNU GPL version 2 http://gnu.org/licenses/gpl.html. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
๐ซถ SEE ALSO ๐ซถ
ndctl-update-passphrase(1), ndctl-remove-passphrase(1)
and that's the whole page bestie, you ate that ๐
โจ this was NDCTL-SETUP-PASSPHRASE(1) from the ndctl manual, brought to you by the ndctl crew, dated 2026-07-07 โ go forth and secure those NVDIMMs, mwah ๐๐
๐ฆ where this page comes from
- fedora 43: ndctl 85-1.fc43 ยท GPL-2.0-only AND LGPL-2.1-only AND CC0-1.0 AND MIT
- fedora 44: ndctl 85-1.fc44 ยท GPL-2.0-only AND LGPL-2.1-only AND CC0-1.0 AND MIT
- ubuntu stonking: ndctl 82-1ubuntu1 ยท LGPL-2.1-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms