tpm: Don't propagate measurement failures to the verifiers layer
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest3 patches 1 replyIn review
- v31 patch 1 replySuperseded
Patches in v4 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | types: make bool generally availablegrub-core/ grub-core/ grub-core/ +2 more | +5 | 0 replies | |
| 2/3 | env: add function for retrieving variables as booleansgrub-core/ include/ | +14 | 0 replies | |
| 3/3 | tpm: Don't propagate measurement failures to the verifiers layerdocs/ grub-core/ | +29 | 0 replies |
Reviews trailers per patch
None of the 3 patches has a Reviewed-by or Acked-by.
| Patch | Javier Martinez Canillas |
|---|---|
| 1/3 | |
| 2/3 | |
| 3/3 | Also-authored-by |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v4 0/3] tpm: Don't propagate measurement failures to the verifiers layer
Address review from Daniel (interdiff attached). I moved the variable parsing into its own function since it has gotten large enough I'd rather it not get rewritten every time we need a variable as a boolean.
Note that I do not have a machine with a broken TPM for testing fallback.
Be well,
--Robbie
Robbie Harwood (3):
types: make bool generally available
env: add function for retrieving variables as booleans
tpm: Don't propagate measurement failures to the verifiers layer
docs/grub.texi | 10 ++++++++++ grub-core/commands/parttool.c | 2 +- grub-core/commands/tpm.c | 21 +++++++++++++++++++-- grub-core/kern/env.c | 13 +++++++++++++ grub-core/loader/arm64/linux.c | 1 - grub-core/parttool/msdospart.c | 4 ++-- include/grub/env.h | 1 + include/grub/parttool.h | 2 +- include/grub/types.h | 1 + 9 files changed, 48 insertions(+), 7 deletions(-)
Interdiff against v3:
docs/grub.texi +3 -2
@@ -3829,8 +3829,9 @@ displaying the menu. See the documentation of @samp{GRUB_TIMEOUT_STYLE} @node tpm_fail_fatal @subsection tpm_fail_fatal -If this variable is enabled, TPM measurements that fail will be treated -as fatal. Otherwise, they will merely be debug-logged and boot will +If this variable is set and true (i.e., not set to ``0'', ``false'', +``disable'', or ``no''), TPM measurements that fail will be treated as +fatal. Otherwise, they will merely be debug-logged and boot will continue.
grub-core/commands/parttool.c +1 -1
@@ -315,7 +315,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),switch (curarg->type) {case GRUB_PARTTOOL_ARG_BOOL : - pargs[curarg - ptool->args].bool + pargs[curarg - ptool->args].b = (args[j][grub_strlen (curarg->name)] !='-' );break ;
grub-core/commands/tpm.c +2 -8
@@ -27,7 +27,6 @@#include <grub/term.h> #include <grub/verify.h> #include <grub/dl.h> -#include <stdbool.h> GRUB_MOD_LICENSE ("GPLv3+" );
@@ -44,12 +43,7 @@ grub_tpm_verify_init (grub_file_t io,static inline bool is_tpm_fail_fatal (void ) { -const char *val =grub_env_get ("tpm_fail_fatal" ); - -if (val ==NULL ||grub_strlen (val) <1 ||grub_strcmp (val,"0" ) ==0 || -grub_strcmp (val,"false" ) ==0 ) -return false; -return true; +return grub_env_get_bool ("tpm_fail_fatal" , false); } static grub_err_t
@@ -85,7 +79,7 @@ grub_tpm_verify_string (char *str, enum grub_verify_string_type type) } description =grub_malloc (grub_strlen (str) +grub_strlen (prefix) +1 );if (!description) -return GRUB_ERR_NONE ; +return grub_errno;grub_memcpy (description, prefix,grub_strlen (prefix));grub_memcpy (description +grub_strlen (prefix), str,grub_strlen (str) +1 );
grub-core/kern/env.c +13 -0
@@ -144,6 +144,19 @@ grub_env_get (const char *name)return var->value; } +bool +grub_env_get_bool (const char *name,bool if_unset) +{ +const char *val =grub_env_get (name); + +if (val ==NULL ||grub_strlen (val) <1 ) +return if_unset; +if (grub_strcmp (val,"0" ) ==0 ||grub_strcmp (val,"false" ) ==0 || +grub_strcmp (val,"disable" ) ==0 ||grub_strcmp (val,"no" ) ==0 ) +return false; +return true; +} +void grub_env_unset (const char *name) {
grub-core/loader/arm64/linux.c +0 -1
@@ -33,7 +33,6 @@#include <grub/i18n.h> #include <grub/lib/cmdline.h> #include <grub/verify.h> -#include <stdbool.h> GRUB_MOD_LICENSE ("GPLv3+" );
grub-core/parttool/msdospart.c +2 -2
@@ -61,7 +61,7 @@ static grub_err_t grub_pcpart_boot (const grub_device_t dev,return grub_errno; } -if (args[0 ].set && args[0 ].bool) +if (args[0 ].set && args[0 ].b) {for (i =0 ; i <4 ; i++) mbr.entries[i].flag =0x0 ;
@@ -116,7 +116,7 @@ static grub_err_t grub_pcpart_type (const grub_device_t dev,if (args[1 ].set) { -if (args[1 ].bool) +if (args[1 ].b) type |=GRUB_PC_PARTITION_TYPE_HIDDEN_FLAG ;else type &= ~GRUB_PC_PARTITION_TYPE_HIDDEN_FLAG ;
include/grub/env.h +1 -0
@@ -45,6 +45,7 @@ struct grub_env_vargrub_err_t EXPORT_FUNC (grub_env_set ) (const char *name,const char *val);const char *EXPORT_FUNC (grub_env_get ) (const char *name); +bool EXPORT_FUNC (grub_env_get_bool ) (const char *name,bool if_unset);void EXPORT_FUNC (grub_env_unset ) (const char *name);struct grub_env_var *EXPORT_FUNC (grub_env_update_get_sorted ) (void );
include/grub/parttool.h +1 -1
@@ -32,7 +32,7 @@ struct grub_parttool_argsint set;union { -int bool; +int b;char *str; }; };
include/grub/types.h +1 -0
@@ -20,6 +20,7 @@#define GRUB_TYPES_HEADER 1#include <config.h> +#include <stdbool.h> #ifndef GRUB_UTIL #include <grub/cpu/types.h> #endif
Signature · 1 line
2.35.1