Skip to content

Commit 933db05

Browse files
a3fsaschahauer
authored andcommitted
bootm: add support for dynamically forcing signature verification
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 <[email protected]> Signed-off-by: Marco Felsch <[email protected]> Link: https://lore.barebox.org/[email protected] Signed-off-by: Sascha Hauer <[email protected]>
1 parent 7c80ebd commit 933db05

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

common/bootm.c

+16
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ static const char * const bootm_verify_names[] = {
8989

9090
static bool force_signed_images = IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES);
9191

92+
void bootm_force_signed_images(void)
93+
{
94+
static unsigned int verify_mode = 0;
95+
96+
if (force_signed_images)
97+
return;
98+
99+
/* recreate bootm.verify with a single enumeration as option */
100+
globalvar_remove("bootm.verify");
101+
globalvar_add_simple_enum("bootm.verify", &verify_mode,
102+
&bootm_verify_names[BOOTM_VERIFY_SIGNATURE], 1);
103+
104+
bootm_verify_mode = BOOTM_VERIFY_SIGNATURE;
105+
force_signed_images = true;
106+
}
107+
92108
bool bootm_signed_images_are_forced(void)
93109
{
94110
return force_signed_images;

include/bootm.h

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ enum bootm_verify bootm_get_verify_mode(void);
153153
void bootm_set_verify_mode(enum bootm_verify mode);
154154

155155
bool bootm_signed_images_are_forced(void);
156+
void bootm_force_signed_images(void);
156157

157158
#define UIMAGE_SOME_ADDRESS (UIMAGE_INVALID_ADDRESS - 1)
158159

0 commit comments

Comments
 (0)