cryptsetup fails unlocking LUKS2 disc with authenticated disc encryption (bundled dm-integrity)
Description
I am aware, that integritysetup support is missing as of today (Mo Dez 18 13:57:29 CET 2023).
Log line after unlocking an --integrity
formatted device in initramfs:
Enter passphrase for /dev/vda3:
device-mapper: reload ioctl on root_dif (252:0) failed: Invvalid argument
Kernel does not support dm-integrity mapping.
No key available with this passphrase.
Enter passphrase for /dev/vda3:
How to reporduce in an vm:
-
setup-alpine
- select crypt and follow all steps but do not reboot - mount /dev/mapper/root to some dir (ex. /media/usb/)
- rsync all disc contents of /dev/mapper/root into some other dir (ex. mkdir /tmp/root/)
rsync
rsync \
--progress \
--verbose \
--inplace \
--no-compress \
--no-whole-file \
--archive \
--acls \
--xattrs \
--delete \
/media/usb/ /tmp/root/
- unmount and reformat /dev/vda3 as integrity backed LUKS2 volume:
cryptsetup -v -c aes-xts-plain64 -s 512 --hash sha512 --pbkdf pbkdf2 --iter-time 5000 --use-random --integrity hmac-sha256 luksFormat /dev/vda3
(the --integrity part is important) - create ext4 filesystem, decrypt and mount the newly created volume and rsync all files back
- chroot into mountpoint (ex. /mnt/usb)
- change UUID for luks volume in /etc/update-extlinux.conf (use blkid | grep crypto_LUKS)
- change UUID for root volume in /etc/fstab
- run update-extlinux and mkinitfs
- reboot and observe
Notes
I think it is better to add integritysetup support and include it in /etc/mkinitfs/mkinitfs.conf instead of adding dm-integrity modules to cryptsetup. So the initramfs is smaller for these folks that do not use authenticated disc encryption
I would like to hear about your opinion before starting to implement the feature in a MR
Edited by Krassy Boykinov