[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <55ae0b6152c84013d483b1bbecb28a425801c408.camel@perches.com>
Date: Wed, 07 Oct 2020 11:27:04 -0700
From: Joe Perches <joe@...ches.com>
To: Colin King <colin.king@...onical.com>,
Mimi Zohar <zohar@...ux.ibm.com>,
Dmitry Kasatkin <dmitry.kasatkin@...il.com>,
James Morris <jmorris@...ei.org>,
"Serge E . Hallyn" <serge@...lyn.com>,
Roberto Sassu <roberto.sassu@...ito.it>,
linux-integrity@...r.kernel.org,
linux-security-module@...r.kernel.org
Cc: kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ima: Fix sizeof mismatches
On Wed, 2020-10-07 at 12:02 +0100, Colin King wrote:
> An incorrect sizeof is being used, sizeof(*fields) is not correct,
> it should be sizeof(**fields). This is not causing a problem since
> the size of these is the same. Fix this in the kmalloc_array and
> memcpy calls.
[]
> diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c
[]
> @@ -216,11 +216,11 @@ int template_desc_init_fields(const char *template_fmt,
> }
>
> if (fields && num_fields) {
> - *fields = kmalloc_array(i, sizeof(*fields), GFP_KERNEL);
> + *fields = kmalloc_array(i, sizeof(**fields), GFP_KERNEL);
> if (*fields == NULL)
> return -ENOMEM;
>
> - memcpy(*fields, found_fields, i * sizeof(*fields));
> + memcpy(*fields, found_fields, i * sizeof(**fields));
Maybe use kmemdup instead.
if (fields && num_fields) {
*fields = kmemdup(found_fields, i * sizeof(**fields), GFP_KERNEL);
etc...
Powered by blists - more mailing lists