Skip to content

Commit 8ecd39c

Browse files
nightmaredmimizohar
authored andcommitted
IMA: prevent SETXATTR_CHECK policy rules with unavailable algorithms
SETXATTR_CHECK policy rules assume that any algorithm listed in the 'appraise_algos' flag must be accepted when performing setxattr() on the security.ima xattr. However nothing checks that they are available in the current kernel. A userland application could hash a file with a digest that the kernel wouldn't be able to verify. However, if SETXATTR_CHECK is not in use, the kernel already forbids that xattr write. Verify that algorithms listed in appraise_algos are available to the current kernel and reject the policy update otherwise. This will fix the inconsistency between SETXATTR_CHECK and non-SETXATTR_CHECK behaviors. That filtering is only performed in ima_parse_appraise_algos() when updating policies so that we do not have to pay the price of allocating a hash object every time validate_hash_algo() is called in ima_inode_setxattr(). Signed-off-by: THOBY Simon <Simon.THOBY@viveris.fr> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
1 parent 4f2946a commit 8ecd39c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

security/integrity/ima/ima_policy.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,12 @@ static unsigned int ima_parse_appraise_algos(char *arg)
12581258
return 0;
12591259
}
12601260

1261+
if (!crypto_has_alg(hash_algo_name[idx], 0, 0)) {
1262+
pr_err("unavailable hash algorithm \"%s\", check your kernel configuration",
1263+
token);
1264+
return 0;
1265+
}
1266+
12611267
/* Add the hash algorithm to the 'allowed' bitfield */
12621268
res |= (1U << idx);
12631269
}

0 commit comments

Comments
 (0)