Skip to content

Commit e837220

Browse files
committed
cryptsetup2 toolstack version bump
cryptsetup2 2.6.1 is a new release that supports reencryption of Q4.2 release LUKS2 volumes. This is a critical feature for the Qubes OS 4.2 release. cryptsetup 2.6.1 requires lvm2 2.03.23, which is also included in this PR. lvm2 in turn requires libaio, which is also included in this PR. util-linux 2.39 is also included in this PR and a dependency of lvm2. patches for reproducible builds are included for all packages. luks-functions is updated to support the new cryptsetup2 version calls reencryption happen in direct-io, offline mode and without locking. from tests, this is best for performance and reliability in single-user mode TODO: - async (AIO) calls are not used. direct-io is used instead. libaio could be hacked out - this could be subject to future work - time to deprecated legacy boards the do not enough space for the new space requirements - x230-legacy, x230-legacy-flash, x230-hotp-legacy - t430-legacy, t430-legacy-flash, t430-hotp-legacy already deprecated Signed-off-by: Thierry Laurion <[email protected]>
1 parent a04158b commit e837220

9 files changed

+789
-293
lines changed

initrd/etc/luks-functions

Lines changed: 56 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -272,19 +272,17 @@ select_luks_container()
272272
DEBUG "Reusing known good LUKS container device from /boot/kexec_key_devices.txt"
273273
DEBUG "LUKS container device: $(cut -d ' ' -f1 /boot/kexec_key_devices.txt)"
274274
LUKS=$(cut -d ' ' -f1 /boot/kexec_key_devices.txt)
275-
else
275+
# LUKS variable not exported yet, prompt for LUKS device
276+
elif [ -z $LUKS ]; then
276277
list_luks_devices > /tmp/luks_devices.txt
277278
#if /tmp/luks_devices.txt exists and is not empty
278279
if [ -s /tmp/luks_devices.txt ]; then
279280
file_selector "/tmp/luks_devices.txt" "Select LUKS container device"
280281
if [ "$FILE" == "" ]; then
281282
return 1
282283
else
284+
#TODO: What about BRTFS multi LUKS setup of QubesOS?
283285
LUKS=$FILE
284-
detect_boot_device
285-
mount -o remount,rw /boot
286-
echo "$LUKS $(cryptsetup luksUUID $LUKS)" >/boot/kexec_key_devices.txt
287-
mount -o remount,ro /boot
288286
fi
289287
else
290288
warn "No encrypted device found"
@@ -303,17 +301,18 @@ test_luks_current_disk_recovery_key_passphrase()
303301
echo -e "\nEnter the current LUKS Disk Recovery Key passphrase (Configured at OS installation or by OEM):"
304302
read -r luks_current_Disk_Recovery_Key_passphrase
305303
echo -n "$luks_current_Disk_Recovery_Key_passphrase" >/tmp/luks_current_Disk_Recovery_Key_passphrase
306-
warn "Testing opening "$LUKS" LUKS encrypted drive content with the current LUKS Disk Recovery Key passphrase..."
307-
cryptsetup open $LUKS test --key-file /tmp/luks_current_Disk_Recovery_Key_passphrase
308304
else
309305
echo -n "$luks_current_Disk_Recovery_Key_passphrase" >/tmp/luks_current_Disk_Recovery_Key_passphrase
310-
warn "Testing opening "$LUKS" LUKS encrypted drive content with the current LUKS Disk Recovery Key passphrase..."
311-
cryptsetup open $LUKS test --key-file /tmp/luks_current_Disk_Recovery_Key_passphrase
312306
fi
313-
#Validate past cryptsetup-reencrypt attempts
314-
if [ $? -eq 0 ]; then
307+
308+
#output test coming and do cryptsetup open call
309+
echo -e "\nTesting opening "$LUKS" LUKS encrypted drive content with the current LUKS Disk Recovery Key passphrase..."
310+
cryptsetup open $LUKS test --key-file /tmp/luks_current_Disk_Recovery_Key_passphrase
311+
312+
#Validate past cryptsetup reencrypt attempts
313+
if [ $? -ne 0 ]; then
315314
whiptail --title 'Invalid Actual LUKS Disk Recovery Key passphrase?' --msgbox \
316-
"If you previously changed it and do not remember it, you will have to\n reinstall the OS from a an external drive.\n\nTo do so, place the ISO file and its signature file on root of an\n external drive, and select Options-> Boot from USB \n\nHit Enter to retry." 30 60
315+
"If you previously changed it and do not remember it, you will have to\n reinstall the OS from a an external drive.\n\nTo do so, place the ISO file and its signature file on root of an\n external drive, and select Options-> Boot from USB \n\nHit Enter to retry." 0 80
317316
shred -n 10 -z -u /tmp/luks_current_Disk_Recovery_Key_passphrase 2>/dev/null
318317
#unsetting luks_current_Disk_Recovery_Key_passphrase so we prompt for it again LUKS Disk Recovery Key passphrase prompt on next round
319318
unset luks_current_Disk_Recovery_Key_passphrase
@@ -323,13 +322,21 @@ test_luks_current_disk_recovery_key_passphrase()
323322
mount -o remount,rw /boot
324323
rm -f /boot/kexec_key_devices.txt
325324
mount -o remount,ro /boot
325+
unset LUKS
326326
else
327327
#LuksOpen test was successful. Cleanup should be called only when done
328328
#Exporting successfully used passphrase possibly reused by oem-factory-reset
329-
329+
echo "Success."
330+
330331
#We close the volume
331332
cryptsetup close test
332333
export luks_current_Disk_Recovery_Key_passphrase
334+
335+
#We export the LUKS volume the was tested valid with passphrase test
336+
export LUKS
337+
#TODO what about non-standard BRTFS multi LUKS containers?
338+
339+
#exit while loop
333340
break;
334341
fi
335342
done
@@ -339,10 +346,6 @@ luks_reencrypt() {
339346
TRACE_FUNC
340347
while :; do
341348
select_luks_container || return 1
342-
#If the user just set a new LUKS Disk Recovery Key passphrase
343-
if [ -n "$luks_new_Disk_Recovery_Key_passphrase" ]; then
344-
luks_current_Disk_Recovery_Key_passphrase="$luks_new_Disk_Recovery_Key_passphrase"
345-
fi
346349
if [ -z "$luks_current_Disk_Recovery_Key_passphrase" ]; then
347350
#if no external provisioning provides current LUKS Disk Recovery Key passphrase
348351
msg=$(echo -e "This will replace the encrypted container content and its LUKS Disk Recovery Key.\n\nThe passphrase associated with this key will be asked from the user under the following conditions:\n 1-Every boot if no Disk Unlock Key was added to the TPM\n 2-If the TPM fails (hardware failure)\n 3-If the firmware has been tampered with/modified by the user\n\nThis process requires you to type the current LUKS Disk Recovery Key passphrase and will delete the LUKS TPM Disk Unlock Key slot, if set up, by setting a default boot LUKS key slot (1) if present.\n\nAt the next prompt, you may be asked to select which file corresponds to the LUKS device container.\n\nHit Enter to continue." | fold -w 70 -s)
@@ -351,17 +354,20 @@ luks_reencrypt() {
351354
echo -e "\nEnter the current LUKS Disk Recovery Key passphrase:"
352355
read -r luks_current_Disk_Recovery_Key_passphrase
353356
echo -n "$luks_current_Disk_Recovery_Key_passphrase" >/tmp/luks_current_Disk_Recovery_Key_passphrase
354-
warn "Reencrypting "$LUKS" LUKS encrypted drive content with a new LUKS Disk Recovery Key. Do NOT shut down or reboot!"
355-
cryptsetup-reencrypt -B 64 --use-directio "$LUKS" --key-slot 0 --key-file /tmp/luks_current_Disk_Recovery_Key_passphrase
356357
else
357358
echo -n "$luks_current_Disk_Recovery_Key_passphrase" >/tmp/luks_current_Disk_Recovery_Key_passphrase
358-
warn "Reencrypting "$LUKS" LUKS encrypted drive content with a new LUKS Disk Recovery Key. Do NOT shut down or reboot!"
359-
cryptsetup-reencrypt -B 64 --use-directio "$LUKS" --key-slot 0 --key-file /tmp/luks_current_Disk_Recovery_Key_passphrase
360359
fi
361-
#Validate past cryptsetup-reencrypt attempts
362-
if [ $(echo $?) -ne 0 ]; then
360+
361+
#Warn and launch actual reencryption
362+
echo -e "\nReencrypting "$LUKS" LUKS encrypted drive content with current Recovery Disk Key passphrase..."
363+
warn "DO NOT POWER DOWN MACHINE, UNPLUG AC OR REMOVE BATTERY DURING REENCRYPTION PROCESS"
364+
cryptsetup reencrypt --resilience=none --force-offline-reencrypt --disable-locks \
365+
"$LUKS" --key-slot 0 --key-file /tmp/luks_current_Disk_Recovery_Key_passphrase
366+
367+
#Validate past cryptsetup reencrypt attempts
368+
if [ $? -ne 0 ]; then
363369
whiptail --title 'Invalid Actual LUKS Disk Recovery Key passphrase?' --msgbox \
364-
"If you previously changed it and do not remember it, you will have to\n reinstall the OS from a an external drive.\n\nTo do so, place the ISO file and its signature file on root of an\n external drive, and select Options-> Boot from USB \n\nHit Enter to retry." 30 60
370+
"If you previously changed it and do not remember it, you will have to\n reinstall the OS from a an external drive.\n\nTo do so, place the ISO file and its signature file on root of an\n external drive, and select Options-> Boot from USB \n\nHit Enter to retry." 0 80
365371
shred -n 10 -z -u /tmp/luks_current_Disk_Recovery_Key_passphrase 2>/dev/null
366372
#unsetting luks_current_Disk_Recovery_Key_passphrase so we prompt for it again LUKS Disk Recovery Key passphrase prompt on next round
367373
unset luks_current_Disk_Recovery_Key_passphrase
@@ -371,11 +377,15 @@ luks_reencrypt() {
371377
mount -o remount,rw /boot
372378
rm -f /boot/kexec_key_devices.txt
373379
mount -o remount,ro /boot
380+
unset LUKS
374381
else
375382
#Reencryption was successful. Cleanup should be called only when done
376383
#Exporting successfully used passphrase possibly reused by oem-factory-reset
377384
export luks_current_Disk_Recovery_Key_passphrase
378-
break;
385+
export LUKS
386+
387+
# we break loop since success
388+
break;
379389
fi
380390
done
381391
}
@@ -388,7 +398,7 @@ luks_change_passphrase()
388398
#if actual or new LUKS Disk Recovery Key is not provisioned by oem-provisioning file
389399
if [ -z "$luks_current_Disk_Recovery_Key_passphrase" ] || [ -z "$luks_new_Disk_Recovery_Key_passphrase" ]; then
390400
whiptail --title 'Changing LUKS Disk Recovery Key passphrase' --msgbox \
391-
"Please enter the current LUKS Disk Recovery Key passphrase (slot 0).\nThen choose a strong passphrase of your own.\n\n**DICEWARE passphrase methodology is STRONGLY ADVISED.**\n\nHit Enter to continue" 30 60
401+
"Please enter the current LUKS Disk Recovery Key passphrase (slot 0).\nThen choose a strong passphrase of your own.\n\n**DICEWARE passphrase methodology is STRONGLY ADVISED.**\n\nHit Enter to continue" 0 80
392402
if [ -z "$luks_new_Disk_Recovery_Key_passphrase" ]; then
393403
echo -e "\nEnter your desired replacement for the actual LUKS Disk Recovery Key passphrase (At least 8 characters long):"
394404
while [[ ${#luks_new_Disk_Recovery_Key_passphrase} -lt 8 ]]; do
@@ -404,21 +414,21 @@ luks_change_passphrase()
404414
export luks_new_Disk_Recovery_Key_passphrase
405415
echo -n "$luks_new_Disk_Recovery_Key_passphrase" >/tmp/luks_new_Disk_Recovery_Key_passphrase
406416
echo -n "$luks_current_Disk_Recovery_Key_passphrase" >/tmp/luks_current_Disk_Recovery_Key_passphrase
407-
warn "Changing "$LUKS" LUKS encrypted disk passphrase to the new LUKS Disk Recovery Key passphrase..."
408-
cryptsetup luksChangeKey "$LUKS" --key-slot 0 --key-file=/tmp/luks_current_Disk_Recovery_Key_passphrase /tmp/luks_new_Disk_Recovery_Key_passphrase
409417
else
410418
#If current and new LUKS Disk Recovery Key were exported
411419
echo -n "$luks_new_Disk_Recovery_Key_passphrase" >/tmp/luks_new_Disk_Recovery_Key_passphrase
412420
echo -n "$luks_current_Disk_Recovery_Key_passphrase" >/tmp/luks_current_Disk_Recovery_Key_passphrase
413-
warn "Changing "$LUKS" LUKS encrypted disk passphrase to the new LUKS Disk Recovery Key passphrase..."
414-
cryptsetup luksChangeKey "$LUKS" --key-slot 0 --key-file=/tmp/luks_current_Disk_Recovery_Key_passphrase /tmp/luks_new_Disk_Recovery_Key_passphrase
415421
fi
416422

423+
#output and do cryptsetup luksChangeKey op
424+
echo -e "\nChanging "$LUKS" LUKS encrypted disk passphrase to the new LUKS Disk Recovery Key passphrase..."
425+
cryptsetup luksChangeKey "$LUKS" --key-slot 0 --key-file=/tmp/luks_current_Disk_Recovery_Key_passphrase /tmp/luks_new_Disk_Recovery_Key_passphrase
426+
417427
#Validate past cryptsetup attempts
418-
if [ $(echo $?) -ne 0 ]; then
428+
if [ $? -ne 0 ]; then
419429
#Cryptsetup luksChangeKey was unsuccessful
420430
whiptail --title 'Invalid LUKS passphrase?' --msgbox \
421-
"The LUKS Disk Recovery Key passphrase was provided to you by the OEM over\n a secure communication channel.\n\nIf you previously changed it and do not remember it,\n you will have to reinstall the OS from a USB drive.\nTo do so, put OS ISO file and it's signature file on root of a USB drive,\n and select Boot from USB\n\nHit Enter to continue." 30 60
431+
"The LUKS Disk Recovery Key passphrase was provided to you by the OEM over\n a secure communication channel.\n\nIf you previously changed it and do not remember it,\n you will have to reinstall the OS from a USB drive.\nTo do so, put OS ISO file and it's signature file on root of a USB drive,\n and select Boot from USB\n\nHit Enter to continue." 0 80
422432
unset luks_current_Disk_Recovery_Key_passphrase
423433
unset luks_new_Disk_Recovery_Key_passphrase
424434
#remove "known good" selected LUKS container so that next pass asks again user to select LUKS container.
@@ -429,10 +439,20 @@ luks_change_passphrase()
429439
mount -o remount,ro /boot
430440
else
431441
#Cryptsetup was successful.
442+
echo "Success."
443+
432444
#Cleanup should be called seperately.
433445
#Exporting successfully used passphrase possibly reused by oem-factory-reset
446+
luks_current_Disk_Recovery_Key_passphrase=$luks_new_Disk_Recovery_Key_passphrase
447+
export luks_current_Disk_Recovery_Key_passphrase
434448
export luks_new_Disk_Recovery_Key_passphrase
435-
break;
449+
450+
#Export chosen LUKS volume
451+
export LUKS
452+
453+
#break loop
454+
#TODO: What about QubesSOS multi LUKS BRTFS deployment?
455+
break;
436456
fi
437457
done
438458
}
@@ -442,6 +462,9 @@ luks_secrets_cleanup()
442462
#Cleanup
443463
shred -n 10 -z -u /tmp/luks_new_Disk_Recovery_Key_passphrase 2>/dev/null || true
444464
shred -n 10 -z -u /tmp/luks_current_Disk_Recovery_Key_passphrase 2>/dev/null || true
465+
466+
#Unset variables if launched in same boot
445467
unset luks_current_Disk_Recovery_Key_passphrase
446468
unset luks_new_Disk_Recovery_Key_passphrase
469+
unset LUKS
447470
}

modules/cryptsetup2

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ modules-$(CONFIG_CRYPTSETUP2) += cryptsetup2
22

33
cryptsetup2_depends := util-linux popt lvm2 json-c $(musl_dep)
44

5-
cryptsetup2_version := 2.3.3
5+
cryptsetup2_version := 2.6.1
66
cryptsetup2_dir := cryptsetup-$(cryptsetup2_version)
77
cryptsetup2_tar := cryptsetup-$(cryptsetup2_version).tar.xz
8-
cryptsetup2_url := https://www.kernel.org/pub/linux/utils/cryptsetup/v2.3/cryptsetup-$(cryptsetup2_version).tar.xz
9-
cryptsetup2_hash := 3bca4ffe39e2f94cef50f6ea65acb873a6dbce5db34fc6bcefe38b6d095e82df
8+
cryptsetup2_url := https://www.kernel.org/pub/linux/utils/cryptsetup/v2.6/cryptsetup-$(cryptsetup2_version).tar.xz
9+
cryptsetup2_hash := 410ded65a1072ab9c8e41added37b9729c087fef4d2db02bb4ef529ad6da4693
1010

1111
# Use an empty prefix so that the executables will not include the
1212
# build path.
@@ -16,9 +16,15 @@ cryptsetup2_configure := \
1616
./configure \
1717
--host $(MUSL_ARCH)-elf-linux \
1818
--prefix "/" \
19+
--enable-internal-sse-argon2 \
1920
--disable-rpath \
2021
--disable-gcrypt-pbkdf2 \
21-
--enable-cryptsetup-reencrypt \
22+
--disable-ssh-token \
23+
--disable-asciidoc \
24+
--disable-nls \
25+
--disable-selinux \
26+
--disable-udev \
27+
--disable-external-tokens \
2228
--with-crypto_backend=kernel \
2329
--with-tmpfilesdir=$(INSTALL)/lib/tmpfiles.d
2430

@@ -33,7 +39,6 @@ cryptsetup2_target := \
3339

3440
cryptsetup2_output := \
3541
.libs/cryptsetup \
36-
.libs/cryptsetup-reencrypt \
3742
.libs/veritysetup \
3843

3944
cryptsetup2_libraries := \

modules/libaio

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
modules-$(CONFIG_LVM2) += libaio
2+
3+
libaio_version := 0.3.113
4+
libaio_dir := libaio-$(libaio_version)
5+
libaio_tar := libaio_$(libaio_version).orig.tar.gz
6+
libaio_url := https://deb.debian.org/debian/pool/main/liba/libaio/$(libaio_tar)
7+
libaio_hash := 2c44d1c5fd0d43752287c9ae1eb9c023f04ef848ea8d4aafa46e9aedb678200b
8+
9+
libaio_target := \
10+
DESTDIR="$(INSTALL)" \
11+
prefix="/" \
12+
$(CROSS_TOOLS) \
13+
install \
14+
&& mv $(build)/$(libaio_dir)/src/libaio.so.1.0.2 $(build)/$(libaio_dir)/src/libaio.so.1 \
15+
16+
libaio_libraries:= src/libaio.so.1
17+
18+
libaio_depends := $(musl_dep)
19+

modules/lvm2

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
modules-$(CONFIG_LVM2) += lvm2
22

3-
lvm2_version := 2.02.168
3+
lvm2_version := 2.03.23
44
lvm2_dir := lvm2.$(lvm2_version)
55
lvm2_tar := LVM2.$(lvm2_version).tgz
66
lvm2_url := https://mirrors.kernel.org/sourceware/lvm2/$(lvm2_tar)
7-
lvm2_hash := 23a3d1cddd41b3ef51812ebf83e9fa491f502fe74130d4263be327a91914660d
7+
lvm2_hash := 74e794a9e9dee1bcf8a2065f65b9196c44fdf321e22d63b98ed7de8c9aa17a5d
88

99
# cross compiling test assumes malloc/realloc aren't glibc compat
1010
# so we force it via the configure cache.
1111
lvm2_configure := \
1212
$(CROSS_TOOLS) \
13-
CFLAGS="-Os" \
14-
PKG_CONFIG=/bin/false \
15-
MODPROBE_CMD=/bin/false \
1613
ac_cv_func_malloc_0_nonnull=yes \
1714
ac_cv_func_realloc_0_nonnull=yes \
1815
./configure \
1916
--host $(MUSL_ARCH)-elf-linux \
20-
--prefix "/" \
17+
--prefix "" \
18+
--libexecdir "/bin" \
19+
--with-optimisation=-Os \
2120
--enable-devmapper \
2221
--disable-selinux \
23-
--disable-udev-systemd-background-jobs \
22+
--without-systemd \
23+
--disable-lvmimportvdo \
2424
--disable-realtime \
25+
--disable-dmfilemapd \
2526
--disable-dmeventd \
26-
--disable-lvmetad \
2727
--disable-lvmpolld \
28+
--disable-readline \
29+
--disable-udev_sync \
30+
--enable-static_link \
2831
--disable-use-lvmlockd \
29-
--disable-use-lvmetad \
3032
--disable-use-lvmpolld \
31-
--disable-blkid_wiping \
33+
--disable-dmfilemapd \
3234
--disable-cmirrord \
3335
--disable-cache_check_needs_check \
3436
--disable-thin_check_needs_check \
@@ -49,10 +51,10 @@ lvm2_target := \
4951
DESTDIR="$(INSTALL)" \
5052
install_device-mapper \
5153

52-
lvm2_libraries := libdm/libdevmapper.so.1.02
54+
lvm2_libraries := libdm/ioctl/libdevmapper.so.1.02
5355

5456
lvm2_output := \
55-
tools/dmsetup \
57+
./libdm/dm-tools/dmsetup \
5658
tools/lvm \
5759

58-
lvm2_depends := util-linux $(musl_dep)
60+
lvm2_depends := util-linux libaio $(musl_dep)

modules/util-linux

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
modules-$(CONFIG_UTIL_LINUX) += util-linux
22

3-
util-linux_version := 2.29.2
3+
util-linux_version := 2.39
44
util-linux_dir := util-linux-$(util-linux_version)
55
util-linux_tar := util-linux-$(util-linux_version).tar.xz
6-
util-linux_url := https://www.kernel.org/pub/linux/utils/util-linux/v2.29/$(util-linux_tar)
7-
util-linux_hash := accea4d678209f97f634f40a93b7e9fcad5915d1f4749f6c47bee6bf110fe8e3
6+
util-linux_url := https://www.kernel.org/pub/linux/utils/util-linux/v2.39/$(util-linux_tar)
7+
util-linux_hash := 32b30a336cda903182ed61feb3e9b908b762a5e66fe14e43efb88d37162075cb
88

99
util-linux_configure := \
1010
$(CROSS_TOOLS) \

0 commit comments

Comments
 (0)