From: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> So far, secure booting systems statically configured CONFIG_BOOTM_FORCE_SIGNED_IMAGES=y to restrict bootm to signed images. This remains the recommended way, but some systems require the ability to decide at runtime whether to enforce secure boot or to disable it, e.g. after verifying a JSON web token with the appropriate claim. For such systems, provide a bootm_force_signed_images() function. There's intentionally no unforce counterpart as this is meant to be non-reversible. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> Signed-off-by: Marco Felsch <m.felsch@xxxxxxxxxxxxxx> --- Changelog: v2: - fix commit message typo - add my s-o-b tag v1: - https://lore.barebox.org/barebox/20231023162748.533468-1-a.fatoum@xxxxxxxxxxxxxx/ common/bootm.c | 16 ++++++++++++++++ include/bootm.h | 1 + 2 files changed, 17 insertions(+) diff --git a/common/bootm.c b/common/bootm.c index 3cd4aa1528a7..c851ab0456b8 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -89,6 +89,22 @@ static const char * const bootm_verify_names[] = { static bool force_signed_images = IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES); +void bootm_force_signed_images(void) +{ + static unsigned int verify_mode = 0; + + if (force_signed_images) + return; + + /* recreate bootm.verify with a single enumeration as option */ + globalvar_remove("bootm.verify"); + globalvar_add_simple_enum("bootm.verify", &verify_mode, + &bootm_verify_names[BOOTM_VERIFY_SIGNATURE], 1); + + bootm_verify_mode = BOOTM_VERIFY_SIGNATURE; + force_signed_images = true; +} + bool bootm_signed_images_are_forced(void) { return force_signed_images; diff --git a/include/bootm.h b/include/bootm.h index e4d59b566edf..98ac5e5a9374 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -153,6 +153,7 @@ enum bootm_verify bootm_get_verify_mode(void); void bootm_set_verify_mode(enum bootm_verify mode); bool bootm_signed_images_are_forced(void); +void bootm_force_signed_images(void); #define UIMAGE_SOME_ADDRESS (UIMAGE_INVALID_ADDRESS - 1) -- 2.39.2