summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-05-31 14:08:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-05-31 14:08:44 -0400
commitd266b3f5cac09434eb624af202f9a31307b34a88 (patch)
treed773c0a422644c9e1e91fc2d89db898e4b4e956a
parent8164c5719b864da3bcfee97ad8af8cfd7ee5ad8c (diff)
parent8cdc23a3d9ec0944000ad43bad588e36afdc38cd (diff)
Merge branch 'next-fixes-for-5.2-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity
Pull integrity subsystem fixes from Mimi Zohar: "Four bug fixes, none 5.2-specific, all marked for stable. The first two are related to the architecture specific IMA policy support. The other two patches, one is related to EVM signatures, based on additional hash algorithms, and the other is related to displaying the IMA policy" * 'next-fixes-for-5.2-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity: ima: show rules with IMA_INMASK correctly evm: check hash algorithm passed to init_desc() ima: fix wrong signed policy requirement when not appraising x86/ima: Check EFI_RUNTIME_SERVICES before using
-rw-r--r--arch/x86/kernel/ima_arch.c5
-rw-r--r--security/integrity/evm/evm_crypto.c3
-rw-r--r--security/integrity/ima/ima_policy.c28
3 files changed, 24 insertions, 12 deletions
diff --git a/arch/x86/kernel/ima_arch.c b/arch/x86/kernel/ima_arch.c
index 85de790583f9..64b973f0e985 100644
--- a/arch/x86/kernel/ima_arch.c
+++ b/arch/x86/kernel/ima_arch.c
@@ -18,6 +18,11 @@ static enum efi_secureboot_mode get_sb_mode(void)
18 18
19 size = sizeof(secboot); 19 size = sizeof(secboot);
20 20
21 if (!efi_enabled(EFI_RUNTIME_SERVICES)) {
22 pr_info("ima: secureboot mode unknown, no efi\n");
23 return efi_secureboot_mode_unknown;
24 }
25
21 /* Get variable contents into buffer */ 26 /* Get variable contents into buffer */
22 status = efi.get_variable(efi_SecureBoot_name, &efi_variable_guid, 27 status = efi.get_variable(efi_SecureBoot_name, &efi_variable_guid,
23 NULL, &size, &secboot); 28 NULL, &size, &secboot);
diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
index e11564eb645b..82a38e801ee4 100644
--- a/security/integrity/evm/evm_crypto.c
+++ b/security/integrity/evm/evm_crypto.c
@@ -89,6 +89,9 @@ static struct shash_desc *init_desc(char type, uint8_t hash_algo)
89 tfm = &hmac_tfm; 89 tfm = &hmac_tfm;
90 algo = evm_hmac; 90 algo = evm_hmac;
91 } else { 91 } else {
92 if (hash_algo >= HASH_ALGO__LAST)
93 return ERR_PTR(-EINVAL);
94
92 tfm = &evm_tfm[hash_algo]; 95 tfm = &evm_tfm[hash_algo];
93 algo = hash_algo_name[hash_algo]; 96 algo = hash_algo_name[hash_algo];
94 } 97 }
diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
index e0cc323f948f..1cc822a59054 100644
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -498,10 +498,11 @@ static void add_rules(struct ima_rule_entry *entries, int count,
498 498
499 list_add_tail(&entry->list, &ima_policy_rules); 499 list_add_tail(&entry->list, &ima_policy_rules);
500 } 500 }
501 if (entries[i].action == APPRAISE) 501 if (entries[i].action == APPRAISE) {
502 temp_ima_appraise |= ima_appraise_flag(entries[i].func); 502 temp_ima_appraise |= ima_appraise_flag(entries[i].func);
503 if (entries[i].func == POLICY_CHECK) 503 if (entries[i].func == POLICY_CHECK)
504 temp_ima_appraise |= IMA_APPRAISE_POLICY; 504 temp_ima_appraise |= IMA_APPRAISE_POLICY;
505 }
505 } 506 }
506} 507}
507 508
@@ -1146,10 +1147,10 @@ enum {
1146}; 1147};
1147 1148
1148static const char *const mask_tokens[] = { 1149static const char *const mask_tokens[] = {
1149 "MAY_EXEC", 1150 "^MAY_EXEC",
1150 "MAY_WRITE", 1151 "^MAY_WRITE",
1151 "MAY_READ", 1152 "^MAY_READ",
1152 "MAY_APPEND" 1153 "^MAY_APPEND"
1153}; 1154};
1154 1155
1155#define __ima_hook_stringify(str) (#str), 1156#define __ima_hook_stringify(str) (#str),
@@ -1209,6 +1210,7 @@ int ima_policy_show(struct seq_file *m, void *v)
1209 struct ima_rule_entry *entry = v; 1210 struct ima_rule_entry *entry = v;
1210 int i; 1211 int i;
1211 char tbuf[64] = {0,}; 1212 char tbuf[64] = {0,};
1213 int offset = 0;
1212 1214
1213 rcu_read_lock(); 1215 rcu_read_lock();
1214 1216
@@ -1232,15 +1234,17 @@ int ima_policy_show(struct seq_file *m, void *v)
1232 if (entry->flags & IMA_FUNC) 1234 if (entry->flags & IMA_FUNC)
1233 policy_func_show(m, entry->func); 1235 policy_func_show(m, entry->func);
1234 1236
1235 if (entry->flags & IMA_MASK) { 1237 if ((entry->flags & IMA_MASK) || (entry->flags & IMA_INMASK)) {
1238 if (entry->flags & IMA_MASK)
1239 offset = 1;
1236 if (entry->mask & MAY_EXEC) 1240 if (entry->mask & MAY_EXEC)
1237 seq_printf(m, pt(Opt_mask), mt(mask_exec)); 1241 seq_printf(m, pt(Opt_mask), mt(mask_exec) + offset);
1238 if (entry->mask & MAY_WRITE) 1242 if (entry->mask & MAY_WRITE)
1239 seq_printf(m, pt(Opt_mask), mt(mask_write)); 1243 seq_printf(m, pt(Opt_mask), mt(mask_write) + offset);
1240 if (entry->mask & MAY_READ) 1244 if (entry->mask & MAY_READ)
1241 seq_printf(m, pt(Opt_mask), mt(mask_read)); 1245 seq_printf(m, pt(Opt_mask), mt(mask_read) + offset);
1242 if (entry->mask & MAY_APPEND) 1246 if (entry->mask & MAY_APPEND)
1243 seq_printf(m, pt(Opt_mask), mt(mask_append)); 1247 seq_printf(m, pt(Opt_mask), mt(mask_append) + offset);
1244 seq_puts(m, " "); 1248 seq_puts(m, " ");
1245 } 1249 }
1246 1250