]> git.baikalelectronics.ru Git - kernel.git/commit
evm: Fix a small race in init_desc()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 12 May 2020 13:19:17 +0000 (16:19 +0300)
committerMimi Zohar <zohar@linux.ibm.com>
Thu, 14 May 2020 23:55:54 +0000 (19:55 -0400)
commite12dae5313e5cc62fe6aaf9e74d0d3832d1773e1
treec85e552f9a199f1996efbd103abebf6dd52cbc63
parentb4c966269a46813b2ebb697f2c322bfc664f5299
evm: Fix a small race in init_desc()

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: Roberto Sassu <roberto.sassu@huawei.com>
Fixes: f16747b92386 ("evm: Check also if *tfm is an error pointer in init_desc()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Roberto Sassu <roberto.sassu@huawei.com>
Acked-by: Krzysztof Struczynski <krzysztof.struczynski@huawei.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
security/integrity/evm/evm_crypto.c