Skip to content

Commit 36824e4

Browse files
authored
Add support of secure warm-boot (sonic-net#2532)
- What I did Add support of secure warm-boot to SONiC. Basically, warm-boot is supporting to load a new kernel without doing full/cold boot. That is by loading a new kernel and exec with kexec Linux command. As a result of that, even when the Secure Boot feature is enabled, still a user or a malicious user can load an unsigned kernel, so to avoid that we added the support of the secure warm boot. More Description about this feature can be found in the Secure Boot HLD: sonic-net/SONiC#1028 - How I did it In general, Linux support it, so I enabled this support by doing the follow steps: I added some special flags in Linux Kernel when user build the sonic-buildimage with secure boot feature enabled. I added a flag "-s" to the kexec command Note: more details in the HLD above. - How to verify it * Good flow: manually just install with sonic-installed a new secure image (a SONiC image that was build with Secure Boot flag enabled) after the secure image is installed, do: warm-reboot Check now that the new kernel is really loaded and switched. * Bad flow: Do the same steps 1-2 as a good flow but with an insecure image (SONiC image that was built without setting Secure Boot enabled) After the insecure image is installed, and triggered warm-boot you should get an error that the new unsigned kernel from the unsecured image was not loaded. Automation test - TBD
1 parent 556d0c6 commit 36824e4

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

scripts/fast-reboot

+19-2
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,20 @@ function load_aboot_secureboot_kernel() {
442442
swipath=$next_image kexec=true loadonly=true ENV_EXTRA_CMDLINE="$BOOT_OPTIONS" bash -
443443
}
444444
445+
function invoke_kexec() {
446+
/sbin/kexec -l "$KERNEL_IMAGE" --initrd="$INITRD" --append="$BOOT_OPTIONS" $@
447+
}
448+
445449
function load_kernel() {
446450
# Load kernel into the memory
447-
/sbin/kexec -a -l "$KERNEL_IMAGE" --initrd="$INITRD" --append="$BOOT_OPTIONS"
451+
invoke_kexec -a
452+
}
453+
454+
function load_kernel_secure() {
455+
# Load kernel into the memory secure
456+
# -s flag is for enforcing the new load kernel(vmlinuz) to be signed and verify.
457+
# not using -a flag, this flag can fallback to an old kexec load that do not support Secure Boot verification
458+
invoke_kexec -s
448459
}
449460
450461
function unload_kernel()
@@ -601,7 +612,13 @@ fi
601612
if is_secureboot && grep -q aboot_machine= /host/machine.conf; then
602613
load_aboot_secureboot_kernel
603614
else
604-
load_kernel
615+
# check if secure boot is enable in UEFI
616+
SECURE_UPGRADE_ENABLED=$(bootctl status 2>/dev/null | grep -c "Secure Boot: enabled")
617+
if [ ${SECURE_UPGRADE_ENABLED} -eq 1 ]; then
618+
load_kernel_secure
619+
else
620+
load_kernel
621+
fi
605622
fi
606623
607624
init_warm_reboot_states

0 commit comments

Comments
 (0)