[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <cf66956ac2df49e6b51cacf94a8a31b9@huawei.com>
Date: Wed, 7 Oct 2020 12:38:43 +0000
From: Roberto Sassu <roberto.sassu@...wei.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-integrity@...r.kernel.org>,
"linux-security-module@...r.kernel.org"
<linux-security-module@...r.kernel.org>
CC: "kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Silviu Vlasceanu" <Silviu.Vlasceanu@...wei.com>
Subject: RE: [PATCH] ima: Fix sizeof mismatches
> From: Colin King [mailto:colin.king@...onical.com]
> Sent: Wednesday, October 7, 2020 1:03 PM
> From: Colin Ian King <colin.king@...onical.com>
>
> 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.
>
> Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
> Fixes: 1bd7face7439 ("ima: allocate field pointers array on demand in
> template_desc_init_fields()")
> Signed-off-by: Colin Ian King <colin.king@...onical.com>
Thanks Colin.
Reviewed-by: Roberto Sassu <roberto.sassu@...wei.com>
Roberto
HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063
Managing Director: Li Peng, Li Jian, Shi Yanli
> ---
> security/integrity/ima/ima_template.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/security/integrity/ima/ima_template.c
> b/security/integrity/ima/ima_template.c
> index 1e89e2d3851f..8884bbf03b43 100644
> --- 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));
> *num_fields = i;
> }
>
> --
> 2.27.0
Powered by blists - more mailing lists