Skip to content

Commit 11220db

Browse files
Huaxin Lumimizohar
Huaxin Lu
authored andcommitted
ima: Fix a potential NULL pointer access in ima_restore_measurement_list
In restore_template_fmt, when kstrdup fails, a non-NULL value will still be returned, which causes a NULL pointer access in template_desc_init_fields. Fixes: c7d0936 ("ima: support restoring multiple template formats") Cc: [email protected] Co-developed-by: Jiaming Li <[email protected]> Signed-off-by: Jiaming Li <[email protected]> Signed-off-by: Huaxin Lu <[email protected]> Reviewed-by: Stefan Berger <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent 0be56a1 commit 11220db

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

security/integrity/ima/ima_template.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,11 @@ static struct ima_template_desc *restore_template_fmt(char *template_name)
340340

341341
template_desc->name = "";
342342
template_desc->fmt = kstrdup(template_name, GFP_KERNEL);
343-
if (!template_desc->fmt)
343+
if (!template_desc->fmt) {
344+
kfree(template_desc);
345+
template_desc = NULL;
344346
goto out;
347+
}
345348

346349
spin_lock(&template_list);
347350
list_add_tail_rcu(&template_desc->list, &defined_templates);

0 commit comments

Comments
 (0)