* [PATCH v3] ima: Fix a potential NULL pointer access in ima_restore_measurement_list
@ 2022-11-02 16:09 Huaxin Lu
2022-11-03 12:04 ` Mimi Zohar
0 siblings, 1 reply; 2+ messages in thread
From: Huaxin Lu @ 2022-11-02 16:09 UTC (permalink / raw)
To: linux-integrity; +Cc: zohar, dmitry.kasatkin
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.
Co-developed-by: Jiaming Li <lijiaming30@huawei.com>
Signed-off-by: Jiaming Li <lijiaming30@huawei.com>
Signed-off-by: Huaxin Lu <luhuaxin1@huawei.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
---
security/integrity/ima/ima_template.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c
index c25079faa..49f062692 100644
--- a/security/integrity/ima/ima_template.c
+++ b/security/integrity/ima/ima_template.c
@@ -340,8 +340,11 @@ static struct ima_template_desc *restore_template_fmt(char *template_name)
template_desc->name = "";
template_desc->fmt = kstrdup(template_name, GFP_KERNEL);
- if (!template_desc->fmt)
+ if (!template_desc->fmt) {
+ kfree(template_desc);
+ template_desc = NULL;
goto out;
+ }
spin_lock(&template_list);
list_add_tail_rcu(&template_desc->list, &defined_templates);
--
2.36.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] ima: Fix a potential NULL pointer access in ima_restore_measurement_list
2022-11-02 16:09 [PATCH v3] ima: Fix a potential NULL pointer access in ima_restore_measurement_list Huaxin Lu
@ 2022-11-03 12:04 ` Mimi Zohar
0 siblings, 0 replies; 2+ messages in thread
From: Mimi Zohar @ 2022-11-03 12:04 UTC (permalink / raw)
To: Huaxin Lu, linux-integrity; +Cc: dmitry.kasatkin
On Thu, 2022-11-03 at 00:09 +0800, Huaxin Lu wrote:
> 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.
>
> Co-developed-by: Jiaming Li <lijiaming30@huawei.com>
> Signed-off-by: Jiaming Li <lijiaming30@huawei.com>
> Signed-off-by: Huaxin Lu <luhuaxin1@huawei.com>
> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
> Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
Thank you. This patch is now queued in next-integrity.
--
Mimi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-03 12:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-02 16:09 [PATCH v3] ima: Fix a potential NULL pointer access in ima_restore_measurement_list Huaxin Lu
2022-11-03 12:04 ` Mimi Zohar
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.