Introduce the use_static_keys flag to indicate that static keys are to be used rather than keys from the PKS storage's DB variable. This variable is set when Secure Boot is enabled with PKS but the DB variable is not present in the PKS storage. The appendedsig module would use this variable to extract the default DB keys from the ELF note and store the keys found there in the trustedlist.
Signed-off-by: Sudhakar Kuppusamy <sudha...@linux.ibm.com> Reviewed-by: Stefan Berger <stef...@linux.ibm.com> Reviewed-by: Avnish Chouhan <avn...@linux.ibm.com> --- .../kern/powerpc/ieee1275/platform_keystore.c | 16 +++++++++++++++- grub-core/term/tparm.c | 1 - .../grub/powerpc/ieee1275/platform_keystore.h | 11 ++++++----- include/grub/types.h | 2 ++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/grub-core/kern/powerpc/ieee1275/platform_keystore.c b/grub-core/kern/powerpc/ieee1275/platform_keystore.c index cf1d0555e..a83fcf7cd 100644 --- a/grub-core/kern/powerpc/ieee1275/platform_keystore.c +++ b/grub-core/kern/powerpc/ieee1275/platform_keystore.c @@ -34,7 +34,11 @@ /* Platform Keystore */ static grub_size_t pks_max_object_size; grub_uint8_t grub_pks_use_keystore = 0; -grub_pks_t grub_pks_keystore = { .db = NULL, .dbx = NULL, .db_entries = 0, .dbx_entries = 0 }; +grub_pks_t grub_pks_keystore = { .db = NULL, + .dbx = NULL, + .db_entries = 0, + .dbx_entries = 0, + .use_static_keys = false }; /* Convert the esl data into the ESL */ static grub_esl_t * @@ -312,6 +316,16 @@ grub_pks_keystore_init (void) grub_memset (&grub_pks_keystore, 0, sizeof (grub_pks_t)); /* DB */ rc = read_secure_boot_variables (0, DB, &grub_pks_keystore.db, &grub_pks_keystore.db_entries); + if (rc == PKS_OBJECT_NOT_FOUND) + { + rc = GRUB_ERR_NONE; + /* + * DB variable won't be available by default in PKS. + * So, it will load the Default Keys from ELF Note + */ + grub_pks_keystore.use_static_keys = true; + } + if (rc == GRUB_ERR_NONE) { /* DBX */ diff --git a/grub-core/term/tparm.c b/grub-core/term/tparm.c index fb5b15a88..f2db325f6 100644 --- a/grub-core/term/tparm.c +++ b/grub-core/term/tparm.c @@ -46,7 +46,6 @@ /* * Common/troublesome character definitions */ -typedef char grub_bool_t; #ifndef FALSE # define FALSE (0) #endif diff --git a/include/grub/powerpc/ieee1275/platform_keystore.h b/include/grub/powerpc/ieee1275/platform_keystore.h index 0641adb0f..870fb8cc5 100644 --- a/include/grub/powerpc/ieee1275/platform_keystore.h +++ b/include/grub/powerpc/ieee1275/platform_keystore.h @@ -199,10 +199,11 @@ struct grub_pks_sd /* The structure of a PKS.*/ struct grub_pks { - grub_pks_sd_t *db; /* signature database */ - grub_pks_sd_t *dbx; /* forbidden signature database */ - grub_size_t db_entries; /* size of signature database */ - grub_size_t dbx_entries; /* size of forbidden signature database */ + grub_pks_sd_t *db; /* signature database */ + grub_pks_sd_t *dbx; /* forbidden signature database */ + grub_size_t db_entries; /* size of signature database */ + grub_size_t dbx_entries; /* size of forbidden signature database */ + grub_bool_t use_static_keys;/* flag to indicate use of static keys */ } GRUB_PACKED; #ifdef __powerpc__ @@ -217,7 +218,7 @@ extern grub_pks_t EXPORT_VAR(grub_pks_keystore); #else #define grub_pks_use_keystore 0 -grub_pks_t grub_pks_keystore = {NULL, NULL, 0, 0}; +grub_pks_t grub_pks_keystore = {NULL, NULL, 0, 0, false}; void grub_pks_free_keystore (void); #endif diff --git a/include/grub/types.h b/include/grub/types.h index ce914decb..865d56a7e 100644 --- a/include/grub/types.h +++ b/include/grub/types.h @@ -397,4 +397,6 @@ struct grub_uuid grub_uint8_t b[GRUB_UUID_SIZE]; }; +typedef char grub_bool_t; + #endif /* ! GRUB_TYPES_HEADER */ -- 2.43.5 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel