Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LUKS unlocking with TPM2 broken on 255-rc3 #30176

Closed
SoapGentoo opened this issue Nov 24, 2023 · 10 comments
Closed

LUKS unlocking with TPM2 broken on 255-rc3 #30176

SoapGentoo opened this issue Nov 24, 2023 · 10 comments
Labels
bug 🐛 Programming errors, that need preferential fixing regression ⚠️ A bug in something that used to work correctly and broke through some recent commit tpm2
Milestone

Comments

@SoapGentoo
Copy link
Contributor

systemd version the issue has been seen with

255-rc3

Used distribution

Gentoo

Linux kernel version used

6.1.63-gentoo-dist

CPU architectures issue was seen on

x86_64

Component

No response

Expected behaviour you didn't see

Booting my Gentoo installation with systemd 255-rc3 should automatically unlock the LUKS root and swap volumes using the TPM slot.

Unexpected behaviour you saw

  1. systemd never unlocks the LUKS volumes using the TPM, instead prompting for the password directly
  2. When rebooting, the kernel panics in libsystemd-shared-255.so

Steps to reproduce the problem

  • systemd 255-rc3
  • LUKS encrypted root and swap (both are discovered using the discoverable partition GUIDs)
  • Using dracut for the initrd and UKI (since in 254, ukify would lead to non-bootable systems), commit 856e7ac
  • Downgrading to 254.6 and re-generating the initrd/UKI makes everything work again

Let me know what other kind of logs you need

Additional program output to the terminal or log subsystem illustrating the issue

No response

@SoapGentoo SoapGentoo added the bug 🐛 Programming errors, that need preferential fixing label Nov 24, 2023
@yuwata yuwata added regression ⚠️ A bug in something that used to work correctly and broke through some recent commit tpm2 labels Nov 24, 2023
@yuwata yuwata added this to the v255 milestone Nov 24, 2023
@poettering
Copy link
Member

Please provide logs of the failure. Otherwise this is not actionable to us.

@poettering poettering added the needs-reporter-feedback ❓ There's an unanswered question, the reporter needs to answer label Nov 24, 2023
@SoapGentoo
Copy link
Contributor Author

what logs exactly? the initrd stuff from the journal?

@poettering
Copy link
Member

ideally debug logs fromt he failing systemd-cryptsetup invocation.

i.e. boot with systemd.log_level=debug on the kernel cmdline to enable debug logs.

@SoapGentoo
Copy link
Contributor Author

I've truncated the logs to just before the root switch.
debug.log

@thesamesam
Copy link
Contributor

I'm hitting the same. I can bisect albeit a bit painfully if needed.

I still see:

# systemd-cryptenroll --tpm2-device=list
PATH        DEVICE      DRIVER
/dev/tpmrm0 MSFT0101:00 tpm_crb

And if I try re-enroll:

This PCR set is already enrolled, executing no operation.

@poettering
Copy link
Member

So you are using the gpt-auto logic for the rootfs?

The cryptsetup invocation is done via:

/usr/bin/systemd-cryptsetup attach root /dev/gpt-auto-root-luks "" tpm2-measure-pcr=yes

i.e. without tpm2-device=auto or similar as switch. Hence it's not surprising the TPM is not queried...

Are you sure this ever worked? I don't see how this could ever have worked.

We probably should imply tpm2-device=auto switch for gpt-auto cryptsetup devices.

@SoapGentoo
Copy link
Contributor Author

SoapGentoo commented Nov 24, 2023

Yes, this works just fine on 254.6, do you want to see the debug logs for this one too?
What command should I put into dracut to test this with cryptsetup?

@poettering
Copy link
Member

Yes, this works just fine on 254.6, do you want to see the debug logs for this one too?

yes

@SoapGentoo
Copy link
Contributor Author

working-254.log

@poettering
Copy link
Member

Oh, I think I understand what's going on. It's this commit which changed behaviour here:

00392b1

It will disable unlocking via token modules if measurement of the root volume key is enabled, because we cannot access the volume key if we use token modules...

Previously, since token support was added to the tree it didn't matter whether tpm2/fido2/pkcs11 support was actually configured in our option string, libcryptsetup would behind our backs try to unlock via a token, because we do a wildcard token unlock. With the above we revert to the old behaviour.

You are relying on that behaviour though, so with the commit above your system is broken.

poettering added a commit to poettering/systemd that referenced this issue Nov 24, 2023
If we detect a TPM, let's also unlock the disk with it, if it has an
enrollment for that.

Fixes: systemd#30176
poettering added a commit to poettering/systemd that referenced this issue Nov 24, 2023
If we detect a TPM, let's also unlock the disk with it, if it has an
enrollment for that.

See: systemd#30176
@YHNdnzj YHNdnzj removed the needs-reporter-feedback ❓ There's an unanswered question, the reporter needs to answer label Nov 25, 2023
YHNdnzj pushed a commit to poettering/systemd that referenced this issue Nov 28, 2023
If we detect a TPM, let's also unlock the disk with it, if it has an
enrollment for that.

Fixes: systemd#30176
@bluca bluca closed this as completed in 0d5f59a Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Programming errors, that need preferential fixing regression ⚠️ A bug in something that used to work correctly and broke through some recent commit tpm2
Development

No branches or pull requests

5 participants