Commit 2de20782 authored by Dan Carpenter's avatar Dan Carpenter Committed by Yongqiang Liu
Browse files

evm: Fix a small race in init_desc()

mainline inclusion
from mainline-v5.7-rc7
commit 84338569
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I6AAU7


CVE: NA

----------------------------------------

The IS_ERR_OR_NULL() function has two conditions and if we got really
unlucky we could hit a race where "ptr" started as an error pointer and
then was set to NULL.  Both conditions would be false even though the
pointer at the end was NULL.

This patch fixes the problem by ensuring that "*tfm" can only be NULL
or valid.  I have introduced a "tmp_tfm" variable to make that work.  I
also reversed a condition and pulled the code in one tab.

Reported-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
Fixes: 53de3b08 ("evm: Check also if *tfm is an error pointer in init_desc()")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Acked-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
Acked-by: default avatarKrzysztof Struczynski <krzysztof.struczynski@huawei.com>
Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>

Conflicts:
	security/integrity/evm/evm_crypto.c

Signed-off-by: default avatarGONG, Ruiqi <gongruiqi1@huawei.com>
Reviewed-by: default avatarWang Weiyang <wangweiyang2@huawei.com>
Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: default avatarYongqiang Liu <liuyongqiang13@huawei.com>
parent 57911670
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment