]> git.baikalelectronics.ru Git - kernel.git/commit
ima: Directly free *entry in ima_alloc_init_template() if digests is NULL
authorRoberto Sassu <roberto.sassu@huawei.com>
Fri, 5 Jun 2020 06:50:28 +0000 (08:50 +0200)
committerMimi Zohar <zohar@linux.ibm.com>
Fri, 5 Jun 2020 10:04:11 +0000 (06:04 -0400)
commit5310e4b47edb4eeeb7b2d315a1d3716f999d24d8
tree3601d25bbbea1399bc3207955e9340bd49fd09fd
parentbf9d70df90122b2b749e03e731440d4f0c5658e5
ima: Directly free *entry in ima_alloc_init_template() if digests is NULL

To support multiple template digests, the static array entry->digest has
been replaced with a dynamically allocated array in commit 0d5f42f43b71
("ima: Switch to dynamically allocated buffer for template digests"). The
array is allocated in ima_alloc_init_template() and if the returned pointer
is NULL, ima_free_template_entry() is called.

However, (*entry)->template_desc is not yet initialized while it is used by
ima_free_template_entry(). This patch fixes the issue by directly freeing
*entry without calling ima_free_template_entry().

Fixes: 0d5f42f43b71 ("ima: Switch to dynamically allocated buffer for template digests")
Reported-by: syzbot+223310b454ba6b75974e@syzkaller.appspotmail.com
Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
security/integrity/ima/ima_api.c