Skip to content

Commit 221be10

Browse files
robertosassumimizohar
authored andcommitted
evm: check hash algorithm passed to init_desc()
This patch prevents memory access beyond the evm_tfm array by checking the validity of the index (hash algorithm) passed to init_desc(). The hash algorithm can be arbitrarily set if the security.ima xattr type is not EVM_XATTR_HMAC. Fixes: 5feeb61 ("evm: Allow non-SHA1 digital signatures") Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> Cc: stable@vger.kernel.org Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
1 parent f400194 commit 221be10

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

security/integrity/evm/evm_crypto.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ static struct shash_desc *init_desc(char type, uint8_t hash_algo)
8989
tfm = &hmac_tfm;
9090
algo = evm_hmac;
9191
} else {
92+
if (hash_algo >= HASH_ALGO__LAST)
93+
return ERR_PTR(-EINVAL);
94+
9295
tfm = &evm_tfm[hash_algo];
9396
algo = hash_algo_name[hash_algo];
9497
}

0 commit comments

Comments
 (0)