Skip to content

Commit 53de3b0

Browse files
robertosassumimizohar
authored andcommitted
evm: Check also if *tfm is an error pointer in init_desc()
This patch avoids a kernel panic due to accessing an error pointer set by crypto_alloc_shash(). It occurs especially when there are many files that require an unsupported algorithm, as it would increase the likelihood of the following race condition: Task A: *tfm = crypto_alloc_shash() <= error pointer Task B: if (*tfm == NULL) <= *tfm is not NULL, use it Task B: rc = crypto_shash_init(desc) <= panic Task A: *tfm = NULL This patch uses the IS_ERR_OR_NULL macro to determine whether or not a new crypto context must be created. Cc: [email protected] Fixes: d46eb36 ("evm: crypto hash replaced by shash") Co-developed-by: Krzysztof Struczynski <[email protected]> Signed-off-by: Krzysztof Struczynski <[email protected]> Signed-off-by: Roberto Sassu <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent 0014cc0 commit 53de3b0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

security/integrity/evm/evm_crypto.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static struct shash_desc *init_desc(char type, uint8_t hash_algo)
9191
algo = hash_algo_name[hash_algo];
9292
}
9393

94-
if (*tfm == NULL) {
94+
if (IS_ERR_OR_NULL(*tfm)) {
9595
mutex_lock(&mutex);
9696
if (*tfm)
9797
goto out;

0 commit comments

Comments
 (0)