Merge ~igor-brovtsin/maas:lp2022084-grub-template into maas:master

Proposed by Igor Brovtsin
Status: Merged
Approved by: Igor Brovtsin
Approved revision: f1b9085690bd76cdd998fb8e90e354b8f4272543
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~igor-brovtsin/maas:lp2022084-grub-template
Merge into: maas:master
Diff against target: 54 lines (+23/-10)
1 file modified
src/provisioningserver/templates/uefi/config.local.amd64.template (+23/-10)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Ghadi Rahme (community) Approve
Adam Collard (community) Approve
Review via email: mp+449355@code.launchpad.net

Commit message

Disable chainloading for third-party distros to fix secure boot

The usual MAAS local boot chain for well-known distros looks like this:

PXE -> MAAS shim -> MAAS GRUB2 -> Distro shim (if any) -> Distro loader

MAAS GRUB chainloads the distro to save time that otherwise the system
would spend trying to netboot with all capable NICs.

Investigating LP:2022084, we discovered that with this chain, RHEL GRUB2
tries to validate the kernel using MAAS shim, causing the secure boot
process to fail. Given the nature of shim and secure boot process in
general, there's not much we can do on MAAS side to fix this behaviour.
As a hotfix, we temporarily drop the chainloading for other distros so
that they could boot securely (even though with some extra wait time).

Ubuntu will still be chainloaded because the MAAS shim trusts the certs
our kernels/bootloaders are signed with. I also don't think Windows
boot loader can be affected by any shims whatsoever, so MAAS will still
try to chainload it.

Description of the change

An accompanying change would be to implement some mechanism that bumps the local boot option to the second place in boot order, with the first one being a MAAS-connected NIC. This will require further investigation though, since even for the virtual machine I used for my tests that had one NIC, there were four ways to netboot it (PXEv4, PXEv6, HTTPv4, HTTPv6). We could bump all four, but ideally there will be a way to pick a suitable one somehow.

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp2022084-grub-template lp:~igor-brovtsin/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 28839e8b1ae75cc0f0293007805f693a279a9a4e

review: Approve
750905c... by Igor Brovtsin

Return exit code 1 when resorting to boot from next device

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp2022084-grub-template lp:~igor-brovtsin/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 750905c674af9b094f1da3183b10966be6d7bcae

review: Approve
Revision history for this message
Adam Collard (adam-collard) wrote :

Have set off a test run for this branch in the lab - let's check if e.g. Windows can deploy

Revision history for this message
Adam Collard (adam-collard) wrote :

LGTM

review: Approve
Revision history for this message
Julian Andres Klode (juliank) wrote :

One could conditionalize the fallback for foreign shims to secure boot only be checking a variable, I think it's $shim_lock but not 100% sure, and might not matter.

Revision history for this message
Julian Andres Klode (juliank) wrote :

Ah I double checked and yes, shim_lock=y is set, so one could duplicate the for loop with the bootloaders being removed and

if [ $shim_lock != "y" ]; then
...
fi

just in case we want to reduce regression potential for existing users.

Revision history for this message
Igor Brovtsin (igor-brovtsin) wrote :

Thanks Julian! I'll update the MP

c6c0539... by Igor Brovtsin

Try chainloading in non-secure-boot scenarios

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp2022084-grub-template lp:~igor-brovtsin/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: c6c05397a55a9a6790d4cfe4cd5df1bc57b85008

review: Approve
Revision history for this message
Ghadi Rahme (ghadi-rahme) :
review: Needs Fixing
f1b9085... by Igor Brovtsin

Enclose `shim_lock` evaluation

Revision history for this message
Igor Brovtsin (igor-brovtsin) :
Revision history for this message
Ghadi Rahme (ghadi-rahme) :
review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp2022084-grub-template lp:~igor-brovtsin/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: f1b9085690bd76cdd998fb8e90e354b8f4272543

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/provisioningserver/templates/uefi/config.local.amd64.template b/src/provisioningserver/templates/uefi/config.local.amd64.template
2index 219a2af..5898d5c 100644
3--- a/src/provisioningserver/templates/uefi/config.local.amd64.template
4+++ b/src/provisioningserver/templates/uefi/config.local.amd64.template
5@@ -4,19 +4,11 @@ set timeout=0
6
7 menuentry 'Local' {
8 echo 'Booting local disk...'
9+ # The bootloader paths list for secure boot is shortened because of LP:2022084
10 for bootloader in \
11 boot/bootx64.efi \
12 ubuntu/shimx64.efi \
13 ubuntu/grubx64.efi \
14- centos/shimx64.efi \
15- centos/grubx64.efi \
16- redhat/shimx64.efi \
17- redhat/grubx64.efi \
18- rhel/shimx64.efi \
19- rhel/grubx64.efi \
20- suse/shim.efi \
21- suse/grubx64.efi \
22- red/grubx64.efi \
23 Microsoft/Boot/bootmgfw.efi; do
24 search --set=root --file /efi/$bootloader
25 if [ $? -eq 0 ]; then
26@@ -24,6 +16,27 @@ menuentry 'Local' {
27 boot
28 fi
29 done
30+
31+ if [ "${shim_lock}" != "y" ]; then
32+ echo 'Secure boot is disabled, trying chainloader...'
33+ for bootloader in \
34+ centos/shimx64.efi \
35+ centos/grubx64.efi \
36+ redhat/shimx64.efi \
37+ redhat/grubx64.efi \
38+ rhel/shimx64.efi \
39+ rhel/grubx64.efi \
40+ suse/shim.efi \
41+ suse/grubx64.efi \
42+ red/grubx64.efi; do
43+ search --set=root --file /efi/$bootloader
44+ if [ $? -eq 0 ]; then
45+ chainloader /efi/$bootloader
46+ boot
47+ fi
48+ done
49+ fi
50+
51 # If no bootloader is found exit and allow the next device to boot.
52- exit
53+ exit 1
54 }

Subscribers

People subscribed via source and target branches