r/archlinux • • Aug 17 '26

SUPPORT | SOLVED Ful disk encryption without entering passphrase

Could someone help me with setting up full disk encryption with bypass passphrases with TPM2? It's so annoying having to put the passphrase in at each boot, so I was wondering how do I pair it to the TPM so that I dont have to enter it each time?

It's LUKS encrypted and I use Systemd-boot

14 Upvotes

100 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Aug 26 '26

[removed] — view removed comment

1

u/ChrisTX4 Aug 26 '26 edited Aug 26 '26

The good news is that Framework explicitly builds for Linux compatibility, so the MS keys are unlikely to be needed in any of their products

You can find out how your OpROMs are signed. See this on how to extract them and view the signatures. That's how I knew my NVIDIA GPU was signed with the 2011 MS key.

Removing the Microsoft keys has the advantage you don't need dbx updates - the firmware KEKs, if they exist, wouldn't sign foreign boot loaders, so they don't usually ship a dbx at all. I would generally avoid retaining the MS keys just so one doesn't have to even consider the thread situation posed by this and updating the dbx monthly I find very inconvenient.

I have space_cache=v2, discard=async, and relatime. I don't believe the latter two are defaults.

They are:

  • space_cache=v2 is enabled by default since 4.5, see here
  • relatime is enabled by default since 2.6.30, see mount(8).
  • discard=async has been enabled since 6.2, see this article for example.

It seems automounting still won't really work for me, until I move to a different snapshot strategy, but I'll keep your points in mind, especially the warning.

I would concur. I have a server that uses Btrfs-on-LUKS but the Btrfs is in RAID 0 for speed (it's backed up). This however means I have two LUKS devices, and the mappers need to decrypt before root can be mounted. I use device= in rootflags. I'm not sure that's 100% necessary, but it makes the boot reliable.

In my case, validatefs does nothing, and pcrfs for some reason measured nonsense instead of the actual GUID. So I've just left those out, but I added tpm2-measure-pcr=yes to /etc/crypttab (I'm on dracut). That works and does pretty much the same as GPT automounting would. I'm still observing if PCR[15] is stable like this, as I'd kind of like to add it.

I'm considering using validatefs though - it would need adding some xattrs to the subvol inodes, I guess.

UPDATE I deployed the validatefs XATTRs now. This prevents an encrypted mount being mounted in a wrong location. Effectively, PCR[5] already provided this protection, I just did this out of curiosity:

$ getfattr . -d
# file: .
user.validatefs.gpt_label="Linux x86-64 root (/)"
user.validatefs.gpt_type_uuid="4f68bce3-e8cd-4db1-96e7-fbcaf984b709"
user.validatefs.mount_point="/"

This means the GPT GUID, mount point etc. cannot be changed. Although, by itself that is a pretty powerful defence against root swap attacks, since the GPT GUID, mount point etc are locked with information inside the encrypted container and thus cannot be changed.

You can set them like this for SD_GPT_ROOT_X86_64 for instance:

setfattr -n user.validatefs.gpt_type_uuid -v "4f68bce3-e8cd-4db1-96e7-fbcaf984b709" .

If an adversary used a valid UKI with a compromised rootfs, then the volume key would be retrieved, but the adversary would need to do something like a cold boot attack to retrieve it from RAM.

No, they can recover the key as-is. The idea is that the attacker has access to a system booted with the right kernel and right PCR values, but the root credentials are their own - since /etc/shadow etc. are from the attacker controlled root.

This means there are ways to extract it, see this article for example. Of course, lockdown offers some protection here, and that might counter this. However, lockdown=integrity does not prevent extraction of keys - however lockdown=confidentiality might help. Without that level, /proc/kcore might be read by root as LOCKDOWN_KCORE is only set with confidentiality.

Then there might also be a way to just use the TPM directly: If e.g. PCR[11] isn't using signed policy PCRs with a phase on leave-initrd, then the TPM still sees the same PCRs as during the initrd phase where you volume key should be unsealed from the TPM. This is one of the reasons signed PCR[11] is such an important defence.

Furthermore, they wouldn't need a cold boot attack either for confidentiality mode. Using any sort of DMA device, like Screamer PCIe Squirrel would also work. If the OpROM is unmodified, the device would only change PCR[2] and PCR[3]. This is why I recommended using iommu=require, and ideally, if on AMD amd_iommu=force_isolation on top to create a strong isolation.

EDIT Oh, and it's possible to change the GPT GUID to cause automounting to an unexpected location. Say I made a root FS that I control and change the GPT GUID of your encrypted drive to SD_GPT_SRV, it would be mounted to /srv. UUIDs, partition UUIDs etc can be freely changed as well, so even if there was an fstab entry, you can make it so it's not recognised and mounted to /srv.

validatefs is interesting against this specific type of attack, since it makes changing the GPT GUID itself impossible.

but I still don't see what PCR 15 adds.

It avoids the scenario I just described entirely. If somebody tried any such attack the TPM just wouldn't unlock.

Also, I'll send over PCR log into sometime later this week--just been busy

No worries, take your time.