Skip to content

Commit 5f3e926

Browse files
tyhicksmimizohar
authored andcommitted
ima: Fail rule parsing when appraise_flag=blacklist is unsupportable
Verifying that a file hash is not blacklisted is currently only supported for files with appended signatures (modsig). In the future, this might change. For now, the "appraise_flag" option is only appropriate for appraise actions and its "blacklist" value is only appropriate when CONFIG_IMA_APPRAISE_MODSIG is enabled and "appraise_flag=blacklist" is only appropriate when "appraise_type=imasig|modsig" is also present. Make this clear at policy load so that IMA policy authors don't assume that other uses of "appraise_flag=blacklist" are supported. Fixes: 273df86 ("ima: Check against blacklisted hashes for files with modsig") Signed-off-by: Tyler Hicks <[email protected]> Reivewed-by: Nayna Jain <[email protected]> Tested-by: Nayna Jain <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent eb624fe commit 5f3e926

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

security/integrity/ima/ima_policy.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,11 @@ static bool ima_validate_rule(struct ima_rule_entry *entry)
10351035
return false;
10361036
}
10371037

1038+
/* Ensure that combinations of flags are compatible with each other */
1039+
if (entry->flags & IMA_CHECK_BLACKLIST &&
1040+
!(entry->flags & IMA_MODSIG_ALLOWED))
1041+
return false;
1042+
10381043
return true;
10391044
}
10401045

@@ -1371,9 +1376,17 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
13711376
result = -EINVAL;
13721377
break;
13731378
case Opt_appraise_flag:
1379+
if (entry->action != APPRAISE) {
1380+
result = -EINVAL;
1381+
break;
1382+
}
1383+
13741384
ima_log_string(ab, "appraise_flag", args[0].from);
1375-
if (strstr(args[0].from, "blacklist"))
1385+
if (IS_ENABLED(CONFIG_IMA_APPRAISE_MODSIG) &&
1386+
strstr(args[0].from, "blacklist"))
13761387
entry->flags |= IMA_CHECK_BLACKLIST;
1388+
else
1389+
result = -EINVAL;
13771390
break;
13781391
case Opt_permit_directio:
13791392
entry->flags |= IMA_PERMIT_DIRECTIO;

0 commit comments

Comments
 (0)