Skip to contentSkip to conversation

boot: don't enable the non-secure boot commands by default if secure boot enabled

PATCH Superseded Rover Mo 4 participants 5 messages Nov 9, 2021 – Apr 12, 2022

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Rover Mo

author
#0 lore raw

PATCH v2 1/1 boot: don't enable the non-secure boot commands by default if secure boot enabled

To prevent booting unsigned images, don't enable the non-secure boot commands(booti, bootz .etc) by default if secure boot enabled.

Cc Heinrich Schuchardt <[email protected]>
Cc Simon Glass <[email protected]>

---

Changes for v2:
- Don't enable the non-secure boot commands too if !EFI_SECURE_BOOT
- Update the help information
- Changed commit title

 cmd/Kconfig         | 11 +++++++++--
 common/Kconfig.boot |  2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)
cmd/Kconfig +9 -2
index 5b30b13e43..98c588e638 100644
@@ -203,15 +203,22 @@ config BOOTM_EFI
 
 config CMD_BOOTZ
 	bool "bootz"
+	default y if !FIT_SIGNATURE && !EFI_SECURE_BOOT
 	help
 	  Boot the Linux zImage
+	  The bootz command is used for launching unsigned Linux zImage.
+	  If you want to have secure boot either via signed FIT images or via
+	  signed UEFI images, this option should be disabled.
 
 config CMD_BOOTI
 	bool "booti"
 	depends on ARM64 || RISCV
-	default y
+	default y if !FIT_SIGNATURE && !EFI_SECURE_BOOT
 	help
-	  Boot an AArch64 Linux Kernel image from memory.
+	  Boot an AArch64/RISC-V Linux Kernel image from memory.
+	  The booti command is used for launching unsigned AArch64 and RISC-V
+	  Linux kernel images. If you want to have secure boot either via signed
+	  FIT images or via signed UEFI images, this option should be disabled.
 
 config BOOTM_LINUX
 	bool "Support booting Linux OS images"
common/Kconfig.boot +1 -1
index a8d4be23a9..574f35b42e 100644
@@ -283,7 +283,7 @@ endif # FIT
 
 config LEGACY_IMAGE_FORMAT
 	bool "Enable support for the legacy image format"
-	default y if !FIT_SIGNATURE
+	default y if !FIT_SIGNATURE && !EFI_SECURE_BOOT
 	help
 	  This option enables the legacy image format. It is enabled by
 	  default for backward compatibility, unless FIT_SIGNATURE is
Signature · 1 line
2.25.1
author
#1 lore raw

Dear Simon Glass,

Quoted 2 lines

Also please do check tests (make qcheck) since sandbox enables more options than most boards.

All tests passed, please check the detailed log in the attachment.

Best regards,
Rover Mo

Quoted 57 lines · Rover Mo

To prevent booting unsigned images, don't enable the non-secure boot commands(booti, bootz .etc) by default if secure boot enabled.

Cc Heinrich Schuchardt <[email protected]>
Cc Simon Glass <[email protected]>

---

Changes for v2:
- Don't enable the non-secure boot commands too if !EFI_SECURE_BOOT
- Update the help information
- Changed commit title

cmd/Kconfig | 11 +++++++++--
common/Kconfig.boot | 2 +-

2 files changed, 10 insertions(+), 3 deletions(-)
cmd/Kconfig +0 -0
index 5b30b13e43..98c588e638 100644
@@ -203,15 +203,22 @@ config BOOTM_EFI
 

config CMD_BOOTZ
bool "bootz"

cmd/Kconfig +1 -0
+	default y if !FIT_SIGNATURE && !EFI_SECURE_BOOT

help
Boot the Linux zImage

cmd/Kconfig +3 -0
+	  The bootz command is used for launching unsigned Linux zImage.
+	  If you want to have secure boot either via signed FIT images or via
+	  signed UEFI images, this option should be disabled.

config CMD_BOOTI

	bool "booti"
	depends on ARM64 || RISCV
cmd/Kconfig +1 -1
-	default y
+	default y if !FIT_SIGNATURE && !EFI_SECURE_BOOT

help

cmd/Kconfig +4 -1
-	  Boot an AArch64 Linux Kernel image from memory.
+	  Boot an AArch64/RISC-V Linux Kernel image from memory.
+	  The booti command is used for launching unsigned AArch64 and RISC-V
+	  Linux kernel images. If you want to have secure boot either via signed
+	  FIT images or via signed UEFI images, this option should be disabled.

config BOOTM_LINUX
bool "Support booting Linux OS images"

common/Kconfig.boot +0 -0
index a8d4be23a9..574f35b42e 100644
@@ -283,7 +283,7 @@ endif # FIT
 

config LEGACY_IMAGE_FORMAT
bool "Enable support for the legacy image format"

common/Kconfig.boot +1 -1
-	default y if !FIT_SIGNATURE
+	default y if !FIT_SIGNATURE && !EFI_SECURE_BOOT
Quoted 5 lines

help
This option enables the legacy image format. It is enabled by default for backward compatibility, unless FIT_SIGNATURE is

Signature · 1 line
2.25.1

/work/open-source/bootloader/u-boot$ make qcheck
./test/run quick
sandbox: +make O=/work/open-source/bootloader/u-boot/build-sandbox -s sandbox_defconfig
+make O=/work/open-source/bootloader/u-boot/build-sandbox -s -j8 ================================================================= test session starts ================================================================== platform linux -- Python 3.8.10, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
rootdir: /work/open-source/bootloader/u-boot/test/py, configfile: pytest.ini
collected 854 items / 111 deselected / 743 selected

test/py/tests/test_000_version.py .                                                                                                              [  0%]
test/py/tests/test_bind.py ..                                                                                                                    [  0%]
test/py/tests/test_button.py ..                                                                                                                  [  0%]
test/py/tests/test_dfu.py s                                                                                                                      [  0%]
test/py/tests/test_dm.py ...                                                                                                                     [  1%]
test/py/tests/test_efi_fit.py .                                                                                                                  [  1%]
test/py/tests/test_efi_loader.py .sss.s                                                                                                          [  2%]
test/py/tests/test_efi_selftest.py sssss                                                                                                         [  2%]
test/py/tests/test_env.py ...............                                                                                                        [  4%]
test/py/tests/test_extension.py .                                                                                                                [  4%]
test/py/tests/test_fit.py .                                                                                                                      [  5%]
test/py/tests/test_fit_ecdsa.py .                                                                                                                [  5%]
test/py/tests/test_fit_hashes.py .                                                                                                               [  5%]
test/py/tests/test_fpga.py ssssssssssssssssssssssssssss                                                                                          [  9%]
test/py/tests/test_gpio.py ..                                                                                                                    [  9%]
test/py/tests/test_gpt.py .......                                                                                                                [ 10%]
test/py/tests/test_handoff.py s                                                                                                                  [ 10%]
test/py/tests/test_help.py .                                                                                                                     [ 10%]
test/py/tests/test_hush_if_test.py ....................................................................                                          [ 19%]
test/py/tests/test_log.py s.                                                                                                                     [ 20%]
test/py/tests/test_lsblk.py .                                                                                                                    [ 20%]
test/py/tests/test_md.py ..                                                                                                                      [ 20%]
test/py/tests/test_mmc_rd.py ssss                                                                                                                [ 20%]
test/py/tests/test_mmc_wr.py s                                                                                                                   [ 21%]
test/py/tests/test_net.py .sssss                                                                                                                 [ 21%]
test/py/tests/test_ofplatdata.py s                                                                                                               [ 22%]
test/py/tests/test_part.py .                                                                                                                     [ 22%]
test/py/tests/test_pinmux.py .......                                                                                                             [ 23%]
test/py/tests/test_pstore.py ...                                                                                                                 [ 23%]
test/py/tests/test_qfw.py ..                                                                                                                     [ 23%]
test/py/tests/test_sandbox_exit.py ..s.                                                                                                          [ 24%]
test/py/tests/test_scp03.py .                                                                                                                    [ 24%]
test/py/tests/test_sf.py ssss                                                                                                                    [ 25%]
test/py/tests/test_shell_basics.py ....                                                                                                          [ 25%]
test/py/tests/test_sleep.py s                                                                                                                    [ 25%]
test/py/tests/test_spl.py s                                                                                                                      [ 25%]
test/py/tests/test_stackprotector.py .                                                                                                           [ 25%]
test/py/tests/test_tpm2.py ...........                                                                                                           [ 27%]
test/py/tests/test_ums.py s                                                                                                                      [ 27%]
test/py/tests/test_unknown_cmd.py .                                                                                                              [ 27%]
test/py/tests/test_ut.py ....................................................................................................................... [ 43%]
................................................................................................................................................ [ 63%]
................................................................................................................................................ [ 82%]
.............................................................................................................                                    [ 97%]
test/py/tests/test_vboot.py ..........                                                                                                           [ 98%]
test/py/tests/test_android/test_ab.py .                                                                                                          [ 98%]
test/py/tests/test_android/test_abootimg.py .                                                                                                    [ 98%]
test/py/tests/test_android/test_avb.py ss..s.                                                                                                    [ 99%]
test/py/tests/test_fs/test_fs_cmd.py .                                                                                                           [ 99%]
test/py/tests/test_fs/test_squashfs/test_sqfs_load.py .                                                                                          [ 99%]
test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py .                                                                                            [100%]

============================================== 681 passed, 62 skipped, 111 deselected in 63.16s (0:01:03) ==============================================
sandbox_spl: +make O=/work/open-source/bootloader/u-boot/build-sandbox_spl -s sandbox_spl_defconfig
+make O=/work/open-source/bootloader/u-boot/build-sandbox_spl -s -j8 ================================================================= test session starts ================================================================== platform linux -- Python 3.8.10, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
rootdir: /work/open-source/bootloader/u-boot/test/py, configfile: pytest.ini
collected 798 items / 787 deselected / 11 selected

test/py/tests/test_handoff.py .                                                                                                                  [  9%]
test/py/tests/test_ofplatdata.py .                                                                                                               [ 18%]
test/py/tests/test_spl.py .........                                                                                                              [100%]

========================================================== 11 passed, 787 deselected in 6.47s ==========================================================
sandbox_spl: +make O=/work/open-source/bootloader/u-boot/build-sandbox_noinst -s sandbox_noinst_defconfig
+make O=/work/open-source/bootloader/u-boot/build-sandbox_noinst -s -j8 ================================================================= test session starts ================================================================== platform linux -- Python 3.8.10, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
rootdir: /work/open-source/bootloader/u-boot/test/py, configfile: pytest.ini
collected 798 items / 787 deselected / 11 selected

test/py/tests/test_handoff.py s                                                                                                                  [  9%]
test/py/tests/test_ofplatdata.py s                                                                                                               [ 18%]
test/py/tests/test_spl.py .........                                                                                                              [100%]

===================================================== 9 passed, 2 skipped, 787 deselected in 6.44s =====================================================
sandbox_flattree: +make O=/work/open-source/bootloader/u-boot/build-sandbox_flattree -s sandbox_flattree_defconfig
+make O=/work/open-source/bootloader/u-boot/build-sandbox_flattree -s -j8 ================================================================= test session starts ================================================================== platform linux -- Python 3.8.10, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
rootdir: /work/open-source/bootloader/u-boot/test/py, configfile: pytest.ini
collected 794 items / 338 deselected / 456 selected

test/py/tests/test_ut.py ....................................................................................................................... [ 26%] ................................................................................................................................................ [ 57%] ................................................................................................................................................ [ 89%]
................................................. [100%]

========================================================= 456 passed, 338 deselected in 8.67s ==========================================================
binman: <unittest.result.TestResult run=322 errors=0 failures=0>
patman: <unittest.result.TestResult run=44 errors=0 failures=0>
buildman: <unittest.result.TestResult run=46 errors=0 failures=0>
fdt: <unittest.result.TestResult run=41 errors=0 failures=0>
dtoc: <unittest.result.TestResult run=62 errors=0 failures=0>
binman code coverage: <unittest.result.TestResult run=322 errors=0 failures=0>
100%
dtoc code coverage: <unittest.result.TestResult run=62 errors=0 failures=0>
100%
fdt code coverage: <unittest.result.TestResult run=41 errors=0 failures=0>
100%
Tests passed!
/work/open-source/bootloader/u-boot$

Reviewed-by Tested-by on v2 1/1
#3 lore raw
In reply to Rover Mo
Quoted 10 lines · Rover Mo

To prevent booting unsigned images, don't enable the non-secure boot commands(booti, bootz .etc) by default if secure boot enabled.

Cc Heinrich Schuchardt <[email protected]>
Cc Simon Glass <[email protected]>

---

Quoted 8 lines

Changes for v2:
- Don't enable the non-secure boot commands too if !EFI_SECURE_BOOT
- Update the help information
- Changed commit title

 cmd/Kconfig         | 11 +++++++++--
 common/Kconfig.boot |  2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)

Tested-on: coral, sandbox

#4 lore raw
In reply to Rover Mo
Quoted 9 lines · Rover Mo

To prevent booting unsigned images, don't enable the non-secure boot commands(booti, bootz .etc) by default if secure boot enabled.

This breaks building on iot_devkit, please test, fix and resubmit, thanks.

Signature · 1 line
Tom