evm: Check also if *tfm is an error pointer in init_desc()
stable inclusion from stable-v4.19.125 commit 4c7a2e76ae93577628a022d2d2adf5e0d8a89147 category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/I6AAU7 CVE: NA ---------------------------------------- [ Upstream commit 53de3b08 ] 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: stable@vger.kernel.org Fixes: d46eb369 ("evm: crypto hash replaced by shash") Co-developed-by:Krzysztof Struczynski <krzysztof.struczynski@huawei.com> Signed-off-by:
Krzysztof Struczynski <krzysztof.struczynski@huawei.com> Signed-off-by:
Roberto Sassu <roberto.sassu@huawei.com> Signed-off-by:
Mimi Zohar <zohar@linux.ibm.com> Signed-off-by:
Sasha Levin <sashal@kernel.org> Signed-off-by:
GONG, Ruiqi <gongruiqi1@huawei.com> Reviewed-by:
Wang Weiyang <wangweiyang2@huawei.com> Reviewed-by:
Xiu Jianfeng <xiujianfeng@huawei.com> Signed-off-by:
Yongqiang Liu <liuyongqiang13@huawei.com>
Loading
Please sign in to comment