lenovo-x1-gen11: Add TPM-backed encryption for the persist partition#1232
lenovo-x1-gen11: Add TPM-backed encryption for the persist partition#1232brianmcgillion merged 2 commits intotiiuae:mainfrom
Conversation
|
Thanks @vunnyso for the review. Especially item 1) is a nice catch. I'll push some changes to address your comments.
This is on purpose to prevent the partition to be decrypted automatically, in the event of a stolen device for example. Do you mean that the PIN should be remembered for a small period of time after the first input? |
Thanks @hros-tii. I mean entering a PIN at every boot is not user-friendly. It would be beneficial if we could make PIN as persistent by trying different TPM configuration registers or another security mechanism. For an additional layer of security, we can enroll mandatory Yubikey presence if needed. |
There was a problem hiding this comment.
Other than the comments, it looks good. Good that we switch to systemd-boot now, would be also useful when implementing systemd-sysupdate.
It is odd that Plymouth doesn't display the PIN, as it should. Maybe it is a problem with the theme or Plymouth isn't configured properly.
|
Hi all, On configuring the TPM without a PIN: an attacker having access to a stolen device that unlocks automatically can use other physical channels to access the disk contents (memory dumps for example). Binding to different PCRs cannot prevent these side-channel attacks as they don't modify any code running on the device. If this setup has to be used, I believe the user should be warned that their data could still be recovered in case their laptop is stolen. Even a weak PIN with a few digits can help mitigate this when coupled with rate limiting from the TPM to prevent brute-force attacks. |
|
The new code is ready for review. A couple things were added:
The setup steps are the same as in the PR description, but in order to verify the new features some more things can be checked. On ghaf-host:
|
|
There is an open upstream bug when using FIDO2 devices to unlock the disk, specifically the models without a PIN input: systemd-cryptsetup + FIDO2 + --fido2-with-client-pin=false: fails to prompt for unlock at boot. There's a race between the kernel detecting the plugged in USB devices and when the cryptsetup service tries to decrypt the partition. In some cases the latter runs first and finds the security token missing, falling back to the passphrase prompt. I could replicate it on the Lenovo laptop, here is how it looks in the logs: |
8ba9bee to
fbf31cd
Compare
Signed-off-by: Hugo Ros <Hugo.Ros@tii.ae>
3d353ce to
f98af55
Compare
f98af55 to
3862e0c
Compare
- enroll persist and swap to chosen backend (TPM or Yubikey) - decrypt both partitions in initrd - add early service to expand swap and persist - btrfs postboot: resize encrypted partitions Signed-off-by: Hugo Ros <Hugo.Ros@tii.ae>
3862e0c to
ab49f48
Compare



Description of Changes
This PR builds upon #1074 which was merged in main as 3f25f73. It builds on top of the dm-verity protected rootfs.
The persist partition is encrypted using the TPM as a LUKS token. An initial step takes place where persist is enrolled to the TPM and a PIN is set. A recovery passphrase is also added to the LUKS header which can optionally be saved and used to later access the partition contents in case of decryption failure. The user is then prompted for the PIN during the boot sequence.
A new user profile is added (mvp-user-trial-hardening). For now selecting this profile only enables the feature described here. It is automatically enabled by the
lenovo-x1-gen11-hardening-debugtarget along with dm-verity.Limitations
This could be implemented in a similar way as for persist, but some modifications could be made for user convenience, to avoid having to input a different PIN for each partition. The decryption step would also need to be moved from user space to initrd.
Type of Change
Checklist
make-checksand it passesx86_64Gen11Testing Instructions
Applicable Targets
aarch64aarch64x86_64x86_64Installation Method
nixos-rebuild ... switchTest Steps To Verify:
lenovo-x1-gen11-hardening-debug-installertarget.dmsetup statusormountto confirm the persist partition is mapped with dm-crypt.