-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
qubes init script and improved TPM disk encryption with LUKS headers …
- Loading branch information
1 parent
d06ba0a
commit f99944a
Showing
7 changed files
with
163 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
# Mount a USB device | ||
die() { echo >&2 "!!!!! $@"; exit 1; } | ||
|
||
if ! lsmod | grep -q ehci_hcd; then | ||
insmod /lib/modules/ehci-hcd.ko \ | ||
|| die "ehci_hcd: module load failed" | ||
fi | ||
if ! lsmod | grep -q ehci_pci; then | ||
insmod /lib/modules/ehci-pci.ko \ | ||
|| die "ehci_pci: module load failed" | ||
fi | ||
|
||
if [ ! -d /media ]; then | ||
mkdir /media | ||
fi | ||
|
||
mount -o ro $1 /media |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/bin/sh | ||
# Boot a Qubes installation that has already been setup. | ||
# This depends on the PCR 4 being "normal-boot": | ||
# f8fa3b6e32e7c6fe04c366e74636e505b28f3b0d | ||
# which is only set if the top level /init script has started | ||
# without user intervention or dropping into a recovery shell. | ||
|
||
recovery() { | ||
echo >&2 "!!!!! $@" | ||
rm -f /tmp/secret.key | ||
tpm extend -ix 4 -if recovery | ||
|
||
echo >&2 "!!!!! Starting recovery shell" | ||
exec /bin/ash | ||
} | ||
|
||
. /config | ||
|
||
# TODO: Allow /boot to be encrypted? | ||
# This would require a different TPM key or a user | ||
# passphrase to decrypt it. | ||
mount -o ro "$CONFIG_QUBES_BOOT_DEV" /boot \ | ||
|| recovery '$CONFIG_BOOT_DEV: Unable to mount /boot' | ||
|
||
# TODO: Allow these to be specified on the /boot device | ||
XEN=/boot/xen-4.6.3.heads | ||
INITRD=/boot/initramfs-4.4.31-11.pvops.qubes.x86_64.img | ||
KERNEL=/boot/vmlinuz-4.4.31-11.pvops.qubes.x86_64 | ||
|
||
echo "+++ Checking $XEN" | ||
gpgv "${XEN}.asc" "${XEN}" \ | ||
|| recovery 'Xen signature failed' | ||
|
||
echo "+++ Checking $INITRD" | ||
gpgv "${INITRD}.asc" "${INITRD}" \ | ||
|| recovery 'Initrd signature failed' | ||
|
||
echo "+++ Checking $KERNEL" | ||
gpgv "${KERNEL}.asc" "${KERNEL}" \ | ||
|| recovery 'Kernel signature failed' | ||
|
||
# Measure the LUKS headers before we unseal the disk key | ||
/bin/qubes-measure-luks $CONFIG_QUBES_DEVS \ | ||
|| recovery "LUKS measure failed" | ||
|
||
# Attempt to unseal the disk key from the TPM | ||
# should we give this some number of tries? | ||
unseal-key \ | ||
|| recovery 'Unseal disk key failed. Starting recovery shell' | ||
|
||
# command line arguments are in the hash, so they are "correct". | ||
kexec \ | ||
-l \ | ||
--module "${KERNEL} root=LABEL=root rhgb" \ | ||
--module "${INITRD}" \ | ||
--command-line "no-real-mode reboot=no console=vga dom0_mem=min:1024M dom0_mem=max:4096M" \ | ||
"${XEN}" \ | ||
|| recovery "kexec load failed" | ||
|
||
# Last step is to override PCR 6 so that user can't read the key | ||
tpm extend -ix 4 -ic qubes \ | ||
|| recovery 'Unable to scramble PCR' | ||
|
||
echo "+++ Starting Qubes..." | ||
exec kexec -e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
# Measure all of the luks disk encryption headers into | ||
# a PCR so that we can detect disk swap attacks. | ||
|
||
die() { echo >&2 "$@"; exit 1; } | ||
|
||
# Measure the luks headers into PCR 6 | ||
for dev in "$@"; do | ||
cryptsetup luksDump $dev \ | ||
|| die "$dev: Unable to measure" | ||
done > /tmp/luksDump.txt | ||
|
||
tpm extend -ix 6 -if /tmp/luksDump.txt \ | ||
|| die "Unable to extend PCR" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters