public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Roberto Sassu <roberto.sassu@huawei.com>
To: Colin King <colin.king@canonical.com>,
	Mimi Zohar <zohar@linux.ibm.com>,
	Dmitry Kasatkin <dmitry.kasatkin@gmail.com>,
	James Morris <jmorris@namei.org>,
	"Serge E . Hallyn" <serge@hallyn.com>,
	Roberto Sassu <roberto.sassu@polito.it>,
	"linux-integrity@vger.kernel.org"
	<linux-integrity@vger.kernel.org>,
	"linux-security-module@vger.kernel.org" 
	<linux-security-module@vger.kernel.org>
Cc: "kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Silviu Vlasceanu" <Silviu.Vlasceanu@huawei.com>
Subject: RE: [PATCH] ima: Fix sizeof mismatches
Date: Wed, 7 Oct 2020 12:38:43 +0000	[thread overview]
Message-ID: <cf66956ac2df49e6b51cacf94a8a31b9@huawei.com> (raw)
In-Reply-To: <20201007110243.19033-1-colin.king@canonical.com>

> From: Colin King [mailto:colin.king@canonical.com]
> Sent: Wednesday, October 7, 2020 1:03 PM
> From: Colin Ian King <colin.king@canonical.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@canonical.com>

Thanks Colin.

Reviewed-by: Roberto Sassu <roberto.sassu@huawei.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


  reply	other threads:[~2020-10-07 12:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-07 11:02 [PATCH] ima: Fix sizeof mismatches Colin King
2020-10-07 12:38 ` Roberto Sassu [this message]
2020-10-07 16:49 ` Jarkko Sakkinen
2020-10-07 18:27 ` Joe Perches
2020-10-12 17:51   ` Mimi Zohar
2020-10-12 18:06     ` Joe Perches
2020-10-12 18:10       ` Colin Ian King
2020-10-13 16:17         ` Mimi Zohar
2020-10-13 16:23           ` Colin Ian King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cf66956ac2df49e6b51cacf94a8a31b9@huawei.com \
    --to=roberto.sassu@huawei.com \
    --cc=Silviu.Vlasceanu@huawei.com \
    --cc=colin.king@canonical.com \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=jmorris@namei.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=roberto.sassu@polito.it \
    --cc=serge@hallyn.com \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox