]> git.baikalelectronics.ru Git - kernel.git/commit
Revert "evm: Fix memleak in init_desc"
authorXiu Jianfeng <xiujianfeng@huawei.com>
Fri, 27 May 2022 11:17:26 +0000 (19:17 +0800)
committerMimi Zohar <zohar@linux.ibm.com>
Wed, 15 Jun 2022 18:03:47 +0000 (14:03 -0400)
commit2d0f7dd7c0aa9820876ad50899da6eff5cac509b
tree8f0854f67dd34036d7e6bf4ca9fe5b7e07001c67
parentb52d5a6d90c5addd271912240e89be49abd74565
Revert "evm: Fix memleak in init_desc"

This reverts commit d8d877d7c772acf52089662f1b971c32293d1089.

Commit d8d877d7c772 ("evm: Fix memleak in init_desc") said there is
memleak in init_desc. That may be incorrect, as we can see, tmp_tfm is
saved in one of the two global variables hmac_tfm or evm_tfm[hash_algo],
then if init_desc is called next time, there is no need to alloc tfm
again, so in the error path of kmalloc desc or crypto_shash_init(desc),
It is not a problem without freeing tmp_tfm.

And also that commit did not reset the global variable to NULL after
freeing tmp_tfm and this makes *tfm a dangling pointer which may cause a
UAF issue.

Reported-by: Guozihua (Scott) <guozihua@huawei.com>
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
security/integrity/evm/evm_crypto.c