Skip to content

Commit f20765f

Browse files
esnowbergmimizohar
authored andcommitted
integrity: Always reference the blacklist keyring with appraisal
Commit 273df86 ("ima: Check against blacklisted hashes for files with modsig") introduced an appraise_flag option for referencing the blacklist keyring. Any matching binary found on this keyring fails signature validation. This flag only works with module appended signatures. An important part of a PKI infrastructure is to have the ability to do revocation at a later time should a vulnerability be found. Expand the revocation flag usage to all appraisal functions. The flag is now enabled by default. Setting the flag with an IMA policy has been deprecated. Without a revocation capability like this in place, only authenticity can be maintained. With this change, integrity can now be achieved with digital signature based IMA appraisal. Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com> Reviewed-by: Nayna Jain <nayna@linux.ibm.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
1 parent 5087fd9 commit f20765f

4 files changed

Lines changed: 19 additions & 24 deletions

File tree

Documentation/ABI/testing/ima_policy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ Description:
5757
stored in security.ima xattr. Requires
5858
specifying "digest_type=verity" first.)
5959

60-
appraise_flag:= [check_blacklist]
61-
Currently, blacklist check is only for files signed with appended
62-
signature.
60+
appraise_flag:= [check_blacklist] (deprecated)
61+
Setting the check_blacklist flag is no longer necessary.
62+
All appraisal functions set it by default.
6363
digest_type:= verity
6464
Require fs-verity's file digest instead of the
6565
regular IMA file hash.

arch/powerpc/kernel/ima_arch.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ bool arch_ima_get_secureboot(void)
2323
* is not enabled.
2424
*/
2525
static const char *const secure_rules[] = {
26-
"appraise func=KEXEC_KERNEL_CHECK appraise_flag=check_blacklist appraise_type=imasig|modsig",
26+
"appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig|modsig",
2727
#ifndef CONFIG_MODULE_SIG
28-
"appraise func=MODULE_CHECK appraise_flag=check_blacklist appraise_type=imasig|modsig",
28+
"appraise func=MODULE_CHECK appraise_type=imasig|modsig",
2929
#endif
3030
NULL
3131
};
@@ -49,9 +49,9 @@ static const char *const trusted_rules[] = {
4949
static const char *const secure_and_trusted_rules[] = {
5050
"measure func=KEXEC_KERNEL_CHECK template=ima-modsig",
5151
"measure func=MODULE_CHECK template=ima-modsig",
52-
"appraise func=KEXEC_KERNEL_CHECK appraise_flag=check_blacklist appraise_type=imasig|modsig",
52+
"appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig|modsig",
5353
#ifndef CONFIG_MODULE_SIG
54-
"appraise func=MODULE_CHECK appraise_flag=check_blacklist appraise_type=imasig|modsig",
54+
"appraise func=MODULE_CHECK appraise_type=imasig|modsig",
5555
#endif
5656
NULL
5757
};

security/integrity/ima/ima_appraise.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -458,11 +458,13 @@ int ima_check_blacklist(struct integrity_iint_cache *iint,
458458
ima_get_modsig_digest(modsig, &hash_algo, &digest, &digestsize);
459459

460460
rc = is_binary_blacklisted(digest, digestsize);
461-
if ((rc == -EPERM) && (iint->flags & IMA_MEASURE))
462-
process_buffer_measurement(&nop_mnt_idmap, NULL, digest, digestsize,
463-
"blacklisted-hash", NONE,
464-
pcr, NULL, false, NULL, 0);
465-
}
461+
} else if (iint->flags & IMA_DIGSIG_REQUIRED && iint->ima_hash)
462+
rc = is_binary_blacklisted(iint->ima_hash->digest, iint->ima_hash->length);
463+
464+
if ((rc == -EPERM) && (iint->flags & IMA_MEASURE))
465+
process_buffer_measurement(&nop_mnt_idmap, NULL, digest, digestsize,
466+
"blacklisted-hash", NONE,
467+
pcr, NULL, false, NULL, 0);
466468

467469
return rc;
468470
}

security/integrity/ima/ima_policy.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,7 @@ static bool ima_validate_rule(struct ima_rule_entry *entry)
12801280
IMA_FSNAME | IMA_GID | IMA_EGID |
12811281
IMA_FGROUP | IMA_DIGSIG_REQUIRED |
12821282
IMA_PERMIT_DIRECTIO | IMA_VALIDATE_ALGOS |
1283-
IMA_VERITY_REQUIRED))
1283+
IMA_CHECK_BLACKLIST | IMA_VERITY_REQUIRED))
12841284
return false;
12851285

12861286
break;
@@ -1355,7 +1355,7 @@ static bool ima_validate_rule(struct ima_rule_entry *entry)
13551355

13561356
/* Ensure that combinations of flags are compatible with each other */
13571357
if (entry->flags & IMA_CHECK_BLACKLIST &&
1358-
!(entry->flags & IMA_MODSIG_ALLOWED))
1358+
!(entry->flags & IMA_DIGSIG_REQUIRED))
13591359
return false;
13601360

13611361
/*
@@ -1803,11 +1803,11 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
18031803
if (entry->flags & IMA_VERITY_REQUIRED)
18041804
result = -EINVAL;
18051805
else
1806-
entry->flags |= IMA_DIGSIG_REQUIRED;
1806+
entry->flags |= IMA_DIGSIG_REQUIRED | IMA_CHECK_BLACKLIST;
18071807
} else if (strcmp(args[0].from, "sigv3") == 0) {
18081808
/* Only fsverity supports sigv3 for now */
18091809
if (entry->flags & IMA_VERITY_REQUIRED)
1810-
entry->flags |= IMA_DIGSIG_REQUIRED;
1810+
entry->flags |= IMA_DIGSIG_REQUIRED | IMA_CHECK_BLACKLIST;
18111811
else
18121812
result = -EINVAL;
18131813
} else if (IS_ENABLED(CONFIG_IMA_APPRAISE_MODSIG) &&
@@ -1816,18 +1816,13 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
18161816
result = -EINVAL;
18171817
else
18181818
entry->flags |= IMA_DIGSIG_REQUIRED |
1819-
IMA_MODSIG_ALLOWED;
1819+
IMA_MODSIG_ALLOWED | IMA_CHECK_BLACKLIST;
18201820
} else {
18211821
result = -EINVAL;
18221822
}
18231823
break;
18241824
case Opt_appraise_flag:
18251825
ima_log_string(ab, "appraise_flag", args[0].from);
1826-
if (IS_ENABLED(CONFIG_IMA_APPRAISE_MODSIG) &&
1827-
strstr(args[0].from, "blacklist"))
1828-
entry->flags |= IMA_CHECK_BLACKLIST;
1829-
else
1830-
result = -EINVAL;
18311826
break;
18321827
case Opt_appraise_algos:
18331828
ima_log_string(ab, "appraise_algos", args[0].from);
@@ -2271,8 +2266,6 @@ int ima_policy_show(struct seq_file *m, void *v)
22712266
}
22722267
if (entry->flags & IMA_VERITY_REQUIRED)
22732268
seq_puts(m, "digest_type=verity ");
2274-
if (entry->flags & IMA_CHECK_BLACKLIST)
2275-
seq_puts(m, "appraise_flag=check_blacklist ");
22762269
if (entry->flags & IMA_PERMIT_DIRECTIO)
22772270
seq_puts(m, "permit_directio ");
22782271
rcu_read_unlock();

0 commit comments

Comments
 (0)