FS#70272 - [systemd] 248-1 breakes LUKS with keyfile
Attached to Project:
Arch Linux
Opened by Nikita Grabar (Slenderchat) - Saturday, 03 April 2021, 00:36 GMT
Last edited by Christian Hesse (eworm) - Wednesday, 14 July 2021, 18:58 GMT
Opened by Nikita Grabar (Slenderchat) - Saturday, 03 April 2021, 00:36 GMT
Last edited by Christian Hesse (eworm) - Wednesday, 14 July 2021, 18:58 GMT
|
Details
Description:
Suddenly after systemd upgrade my server and laptop, which is LUKS encrypted and uses systemd-cryptsetup with keys in initramfs and root filesystem to auto-unlock, started to boot to emergency shell (photo of output will be attached). I started to investigate the problem, and find out that culprit was systemd-cryptsetup@root unit. Logs for that unit contained this error: "Failed to load key file "root.key": Argument list too long". After i extracted keys from initramfs file and chrooted to my broken systems, I decided to downgrade systemd to 247.4-2. After it was done and after initcpios was updated, both systems booted succesfully. This is the only change which was done and it helped, so the culprit is systemd 248-1. Seems to be, that Steps to reproduce: 1. Setup system with LUKS full disk encryption which uses systemd-cryptsetup to auto-unlock partitions on boot with keyfiles in initcpios; 2. Make sure that you've replaced udev hook with systemd hook in mkinitcpio.conf, added sd-encrypt hook, and included /etc/cryptsetup-keys.d/root.key in FILES array; 3. Make sure, that you use systemd >= 248; 4. Try to boot. P.S. Unfortunately I only captured output of server, which has "quiet" in kernel parameters. All other information was gained on laptop by removing "quiet" option, and by including /etc/shadow in initcpio's to get emergency shell access. |
This task depends upon
Closed by Christian Hesse (eworm)
Wednesday, 14 July 2021, 18:58 GMT
Reason for closing: Fixed
Additional comments about closing: systemd 249
Wednesday, 14 July 2021, 18:58 GMT
Reason for closing: Fixed
Additional comments about closing: systemd 249
Error was "Apr 02 17:37:32 arch-server systemd-cryptsetup[247]: Failed to activate with key file '/etc/keys/[UUID].key': Invalid argument."
Downgraded to 247.4-2 and boots without error.
> Failed to activate with key file '/etc/crypttab.key': Invalid argument
I filed a ticket upstream: https://github.com/systemd/systemd/issues/19193
> libfido2 provides library functionality and command-line tools to communicate with a FIDO device over USB, and to verify attestation and assertion signatures.
Are those two different issues?
The bug appears to be in systemd-cryptsetup, specifically the "Invalid Argument" error message appears to originate in the code that reads the keyfile from the disk - https://github.com/systemd/systemd/blob/34fde9f898f63096262d95c61d75db85dabe6fe4/src/cryptsetup/cryptsetup.c#L1222
My guess would be that the bug is triggered by the crypt_activate_by_passphrase function, but I don't know the codebase well enough to attempt to debug further than this.
I can confirm that this issue also occurs for me with systemd version 248 and that downgrading to 247.4-2 works.
My system is configured to unlock the encrypted /home partition (which is on a secondary drive) automatically with a keyfile - /etc/cryptsetup-keys.d/home.key.
After upgrading to systemd-248, the system boots in emergency mode. However, I am able to correctly mount my home partition using both the said keyfile and the passphrase.
The issue is not present anymore after downgrading to systemd-247
Right now I downgraded, but that is very unfortunate for a systems core component.
Is this already filed as bug at the systemd github repo?
Downgrading to 247.4-2 solves that issue.
FS#70264(see initial report) did not solve this issue.Also no indication that there will be a solution from upstream soon.
Relevant journal attached.
At least that looks like progress!
That being said... I could build packages for v249-rc1 and create a separate repository if you are interested.
If the fix is backported to the stable branch I will push an update to the repositories of course.
https://github.com/systemd/systemd/milestone/26