mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-06 05:06:29 +00:00
ima: Fix misuse of dereference of pointer in template_desc_init_fields()
[ Upstream commit25369175ce
] The input parameter @fields is type of struct ima_template_field ***, so when allocates array memory for @fields, the size of element should be sizeof(**field) instead of sizeof(*field). Actually the original code would not cause any runtime error, but it's better to make it logically right. Fixes:adf53a778a
("ima: new templates management mechanism") Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> Reviewed-by: Roberto Sassu <roberto.sassu@huawei.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
c591c48842
commit
d2845542a9
@ -245,11 +245,11 @@ int template_desc_init_fields(const char *template_fmt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fields && num_fields) {
|
if (fields && num_fields) {
|
||||||
*fields = kmalloc_array(i, sizeof(*fields), GFP_KERNEL);
|
*fields = kmalloc_array(i, sizeof(**fields), GFP_KERNEL);
|
||||||
if (*fields == NULL)
|
if (*fields == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
memcpy(*fields, found_fields, i * sizeof(*fields));
|
memcpy(*fields, found_fields, i * sizeof(**fields));
|
||||||
*num_fields = i;
|
*num_fields = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user