integrity: improve user feedback for invalid bootparams
Subsystems (4)
v2 cover integrity: improve user feedback for invalid bootparams
Some boot paramenters under integrity/ don't report any feedback to the user in case an invalid/unknown option is passed. With this patch, try to be more informative about what went wrong, including a more strict secure boot feedback.
Bruno Meneguele (4):
ima: add check for enforced appraise option
integrity: invalid kernel parameters feedback
ima: limit secure boot feedback scope for appraise
integrity: prompt keyring name for unknown key request
security/integrity/digsig_asymmetric.c | 10 ++++++++-- security/integrity/evm/evm_main.c | 3 +++ security/integrity/ima/ima_appraise.c | 27 ++++++++++++++++++-------- security/integrity/ima/ima_main.c | 13 +++++++++---- security/integrity/ima/ima_policy.c | 2 ++ 5 files changed, 41 insertions(+), 14 deletions(-)
Signature · 1 line
2.26.2
PATCH v2 1/4 ima: add check for enforced appraise option
The "enforce" string is allowed as an option for ima_appraise= kernel paramenter per kernel-paramenters.txt and should be considered on the parameter setup checking as a matter of completeness. Also it allows futher checking on the options being passed by the user.
--- security/integrity/ima/ima_appraise.c | 2 ++ 1 file changed, 2 insertions(+)
security/integrity/ima/ima_appraise.c +2 -0
@@ -31,6 +31,8 @@ static int __init default_appraise_setup(char *str) ima_appraise =IMA_APPRAISE_LOG ; else if (strncmp(str, "fix", 3) == 0) ima_appraise =IMA_APPRAISE_FIX ; + else if (strncmp(str, "enforce", 7) == 0) + ima_appraise =IMA_APPRAISE_ENFORCE ;#endif return 1 ; }
Signature · 1 line
2.26.2
PATCH v2 2/4 integrity: invalid kernel parameters feedback
In reply to Bruno MenegueleDon't silently ignore unknown or invalid ima_{policy,appraise,hash} and evm kernel boot command line options.
---
Changelog:
v2: update commit message (Mimi)
security/integrity/evm/evm_main.c | 3 +++ security/integrity/ima/ima_appraise.c | 2 ++ security/integrity/ima/ima_main.c | 13 +++++++++---- security/integrity/ima/ima_policy.c | 2 ++ 4 files changed, 16 insertions(+), 4 deletions(-)
security/integrity/evm/evm_main.c +3 -0
@@ -59,6 +59,9 @@ static int __init evm_set_fixmode(char *str) {if (strncmp (str,"fix" ,3 ) ==0 ) evm_fixmode =1 ; +else +pr_err ("invalid \"%s\" mode" , str); +return 0 ; }__setup ("evm=" , evm_set_fixmode);
security/integrity/ima/ima_appraise.c +2 -0
@@ -33,6 +33,8 @@ static int __init default_appraise_setup(char *str) ima_appraise =IMA_APPRAISE_FIX ; else if (strncmp(str, "enforce", 7) == 0) ima_appraise =IMA_APPRAISE_ENFORCE ; + else + pr_err("invalid \"%s\" appraise option", str);#endif return 1 ; }
security/integrity/ima/ima_main.c +9 -4
@@ -50,18 +50,23 @@ static int __init hash_setup(char *str)return 1 ;if (strcmp (template_desc->name,IMA_TEMPLATE_IMA_NAME ) ==0 ) { -if (strncmp (str,"sha1" ,4 ) ==0 ) +if (strncmp (str,"sha1" ,4 ) ==0 ) { ima_hash_algo =HASH_ALGO_SHA1 ; -else if (strncmp (str,"md5" ,3 ) ==0 ) + }else if (strncmp (str,"md5" ,3 ) ==0 ) { ima_hash_algo =HASH_ALGO_MD5 ; -else + }else { +pr_err ("invalid hash algorithm \"%s\" for template \"%s\"" , + str,IMA_TEMPLATE_IMA_NAME );return 1 ; + } goto out; } i =match_string (hash_algo_name,HASH_ALGO__LAST , str); -if (i <0 ) +if (i <0 ) { +pr_err ("invalid hash algorithm \"%s\"" , str);return 1 ; + } ima_hash_algo = i; out:
security/integrity/ima/ima_policy.c +2 -0
@@ -240,6 +240,8 @@ static int __init policy_setup(char *str) ima_use_secure_boot = true; else if (strcmp(p, "fail_securely") == 0) ima_fail_unverifiable_sigs = true; + else + pr_err("policy \"%s\" not found", p); }return 1 ;
Signature · 1 line
2.26.2
PATCH v2 3/4 ima: limit secure boot feedback scope for appraise
In reply to Bruno MenegueleOnly prompt the unknown/invalid appraisal option if secureboot is enabled and if the current state differentiates from the original one.
---
Changelog:
v2:
- update commit message (Mimi)
- work with a temporary var instead of directly with ima_appraise (Mimi)
security/integrity/ima/ima_appraise.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
security/integrity/ima/ima_appraise.c +16 -9
@@ -19,22 +19,29 @@static int __init default_appraise_setup (char *str) {#ifdef CONFIG_IMA_APPRAISE_BOOTPARAM -if (arch_ima_get_secureboot ()) { -pr_info ("Secure boot enabled: ignoring ima_appraise=%s boot parameter option" , - str); -return 1 ; - } +bool sb_state =arch_ima_get_secureboot (); +int appraisal_state = ima_appraise;if (strncmp (str,"off" ,3 ) ==0 ) - ima_appraise =0 ; + appraisal_state =0 ;else if (strncmp (str,"log" ,3 ) ==0 ) - ima_appraise =IMA_APPRAISE_LOG ; + appraisal_state =IMA_APPRAISE_LOG ;else if (strncmp (str,"fix" ,3 ) ==0 ) - ima_appraise =IMA_APPRAISE_FIX ; + appraisal_state =IMA_APPRAISE_FIX ;else if (strncmp (str,"enforce" ,7 ) ==0 ) - ima_appraise =IMA_APPRAISE_ENFORCE ; + appraisal_state =IMA_APPRAISE_ENFORCE ;else pr_err ("invalid \"%s\" appraise option" , str); + +/* If appraisal state was changed, but secure boot is enabled, +* keep its default */ +if (sb_state) { +if (!(appraisal_state &IMA_APPRAISE_ENFORCE )) +pr_info ("Secure boot enabled: ignoring ima_appraise=%s option" , + str); +else + ima_appraise = appraisal_state; + }#endif return 1 ; }
Signature · 1 line
2.26.2
Mimi Zohar
maintainerRe: [PATCH v2 3/4] ima: limit secure boot feedback scope for appraise
Hi Bruno,
Quoted 17 lines
security/integrity/ima/ima_appraise.c +6
-4+bool sb_state =arch_ima_get_secureboot (); +int appraisal_state = ima_appraise;if (strncmp (str,"off" ,3 ) ==0 ) - ima_appraise =0 ; + appraisal_state =0 ;else if (strncmp (str,"log" ,3 ) ==0 ) - ima_appraise =IMA_APPRAISE_LOG ; + appraisal_state =IMA_APPRAISE_LOG ;else if (strncmp (str,"fix" ,3 ) ==0 ) - ima_appraise =IMA_APPRAISE_FIX ; + appraisal_state =IMA_APPRAISE_FIX ;else if (strncmp (str,"enforce" ,7 ) ==0 ) - ima_appraise =IMA_APPRAISE_ENFORCE ; + appraisal_state =IMA_APPRAISE_ENFORCE ;else pr_err ("invalid \"%s\" appraise option" , str);
security/integrity/ima/ima_appraise.c line 44
Quoted 10 lines
security/integrity/ima/ima_appraise.c +10
-0+ +/* If appraisal state was changed, but secure boot is enabled, +* keep its default */ +if (sb_state) { +if (!(appraisal_state &IMA_APPRAISE_ENFORCE )) +pr_info ("Secure boot enabled: ignoring ima_appraise=%s option" , + str); +else + ima_appraise = appraisal_state; + }
Shouldn't the "else" clause be here. No need to re-post the entire
patch set.
thanks,
Mimi
Quoted 3 lines
#endif
return 1;
}
Re: [PATCH v2 3/4] ima: limit secure boot feedback scope for appraise
Quoted 24 lines · Mimi Zohar
Hi Bruno,
Quoted 22 lines
security/integrity/ima/ima_appraise.c +11
-4+bool sb_state =arch_ima_get_secureboot (); +int appraisal_state = ima_appraise;if (strncmp (str,"off" ,3 ) ==0 ) - ima_appraise =0 ; + appraisal_state =0 ;else if (strncmp (str,"log" ,3 ) ==0 ) - ima_appraise =IMA_APPRAISE_LOG ; + appraisal_state =IMA_APPRAISE_LOG ;else if (strncmp (str,"fix" ,3 ) ==0 ) - ima_appraise =IMA_APPRAISE_FIX ; + appraisal_state =IMA_APPRAISE_FIX ;else if (strncmp (str,"enforce" ,7 ) ==0 ) - ima_appraise =IMA_APPRAISE_ENFORCE ; + appraisal_state =IMA_APPRAISE_ENFORCE ;else pr_err ("invalid \"%s\" appraise option" , str); + +/* If appraisal state was changed, but secure boot is enabled, +* keep its default */ +if (sb_state) { +if (!(appraisal_state &IMA_APPRAISE_ENFORCE ))
Quoted 8 lines
security/integrity/ima/ima_appraise.c line 44
Quoted 5 lines
security/integrity/ima/ima_appraise.c +5
-0+pr_info ("Secure boot enabled: ignoring ima_appraise=%s option" , + str); + else + ima_appraise = appraisal_state; + }Shouldn't the "else" clause be here. No need to re-post the entire
patch set.
Yes, of course it should.
Sorry. Sending the v3 for this patch.
Quoted 10 lines
thanks,
Mimi
Quoted 3 lines
#endif
return 1;
}
Signature · 2 lines
bmeneg PGP Key: http://bmeneg.com/pubkey.txt
PATCH v3 3/4 ima: limit secure boot feedback scope for appraise
In reply to Bruno MenegueleOnly prompt the unknown/invalid appraisal option if secureboot is enabled and if the current appraisal state is different from the original one.
---
Changelog:
v3:
- fix sb_state conditional (Mimi)
v2:
- update commit message (Mimi)
- work with a temporary var instead of directly with ima_appraise (Mimi)
security/integrity/ima/ima_appraise.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
security/integrity/ima/ima_appraise.c +16 -9
@@ -19,22 +19,29 @@static int __init default_appraise_setup (char *str) {#ifdef CONFIG_IMA_APPRAISE_BOOTPARAM -if (arch_ima_get_secureboot ()) { -pr_info ("Secure boot enabled: ignoring ima_appraise=%s boot parameter option" , - str); -return 1 ; - } +bool sb_state =arch_ima_get_secureboot (); +int appraisal_state = ima_appraise;if (strncmp (str,"off" ,3 ) ==0 ) - ima_appraise =0 ; + appraisal_state =0 ;else if (strncmp (str,"log" ,3 ) ==0 ) - ima_appraise =IMA_APPRAISE_LOG ; + appraisal_state =IMA_APPRAISE_LOG ;else if (strncmp (str,"fix" ,3 ) ==0 ) - ima_appraise =IMA_APPRAISE_FIX ; + appraisal_state =IMA_APPRAISE_FIX ;else if (strncmp (str,"enforce" ,7 ) ==0 ) - ima_appraise =IMA_APPRAISE_ENFORCE ; + appraisal_state =IMA_APPRAISE_ENFORCE ;else pr_err ("invalid \"%s\" appraise option" , str); + +/* If appraisal state was changed, but secure boot is enabled, +* keep its default */ +if (sb_state) { +if (!(appraisal_state &IMA_APPRAISE_ENFORCE )) +pr_info ("Secure boot enabled: ignoring ima_appraise=%s option" , + str); + }else { + ima_appraise = appraisal_state; + }#endif return 1 ; }
Signature · 1 line
2.26.2
Mimi Zohar
maintainerRe: [PATCH v3 3/4] ima: limit secure boot feedback scope for appraise
Hi Bruno,
Quoted 4 lines · Bruno Meneguele
Only prompt the unknown/invalid appraisal option if secureboot is enabled and if the current appraisal state is different from the original one.
Signed-off-by Bruno Meneguele <[email protected]>
Thanks. I tweaked this patch description and that of 4/4. This patch set is in next-integrity-testing. Please take a look.
thanks,
Mimi
Re: [PATCH v3 3/4] ima: limit secure boot feedback scope for appraise
Quoted 11 lines · Mimi Zohar
Hi Bruno,
Quoted 4 lines · Bruno Meneguele
Only prompt the unknown/invalid appraisal option if secureboot is enabled and if the current appraisal state is different from the original one.
Signed-off-by Bruno Meneguele <[email protected]>Thanks. I tweaked this patch description and that of 4/4. This patch set is in next-integrity-testing. Please take a look.
Thanks Mimi! Just checked in the branch and they're fine.
Quoted 4 lines
thanks,
Mimi
Signature · 2 lines
bmeneg PGP Key: http://bmeneg.com/pubkey.txt
PATCH v2 4/4 integrity: prompt keyring name for unknown key request
In reply to Bruno MenegueleDepending on the IMA policy a key can be searched in multiple keyrings (e.g. .ima and .platform) and possibly failing for both. However, for the user not aware of the searching order it's not clear what's the keyring the kernel didn't find the key. With this patch we improve this feedback by printing the keyring "description" (name).
--- security/integrity/digsig_asymmetric.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
security/integrity/digsig_asymmetric.c +8 -2
@@ -55,8 +55,14 @@ static struct key *request_asymmetric_key(struct key *keyring, uint32_t keyid) }if (IS_ERR (key)) { -pr_err_ratelimited ("Request for unknown key '%s' err %ld\n" , - name,PTR_ERR (key)); +if (keyring) +pr_err_ratelimited ("Request for unknown key '%s' in '%s' keyring. err %ld\n" , + name, keyring->description, +PTR_ERR (key)); +else +pr_err_ratelimited ("Request for unknown key '%s' err %ld\n" , + name,PTR_ERR (key)); +switch (PTR_ERR (key)) {/* Hide some search errors */ case -EACCES :
Signature · 1 line
2.26.2