public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Roberto Sassu <roberto.sassu@huawei.com>
To: Xiujianfeng <xiujianfeng@huawei.com>,
	"zohar@linux.ibm.com" <zohar@linux.ibm.com>,
	"dmitry.kasatkin@gmail.com" <dmitry.kasatkin@gmail.com>,
	"paul@paul-moore.com" <paul@paul-moore.com>,
	"jmorris@namei.org" <jmorris@namei.org>,
	"serge@hallyn.com" <serge@hallyn.com>,
	"roberto.sassu@polito.it" <roberto.sassu@polito.it>
Cc: "linux-integrity@vger.kernel.org"
	<linux-integrity@vger.kernel.org>,
	"linux-security-module@vger.kernel.org" 
	<linux-security-module@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] ima: Fix misuse of dereference of pointer in template_desc_init_fields()
Date: Mon, 14 Nov 2022 08:37:57 +0000	[thread overview]
Message-ID: <55100c2e550b4649b5a751ca4596fe7c@huawei.com> (raw)
In-Reply-To: <20221112092719.224888-1-xiujianfeng@huawei.com>

> From: Xiujianfeng
> Sent: Saturday, November 12, 2022 10:27 AM
> The input parameter @fields is type of struct ima_template_field ***, so
> when allocates array memory for @fields, the size of element should be
> sizeof(**field) instead of sizeof(*field).
> 
> Actually the original code would not cause any runtime error, but it's
> better to make it logically right.
> 
> Fixes: adf53a778a0a ("ima: new templates management mechanism")
> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>

Reviewed-by: Roberto Sassu <roberto.sassu@huawei.com>

Thanks

Roberto

> ---
>  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 49f0626928a1..04c49f05cb74 100644
> --- a/security/integrity/ima/ima_template.c
> +++ b/security/integrity/ima/ima_template.c
> @@ -245,11 +245,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.17.1


  reply	other threads:[~2022-11-14  8:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-12  9:27 [PATCH] ima: Fix misuse of dereference of pointer in template_desc_init_fields() Xiu Jianfeng
2022-11-14  8:37 ` Roberto Sassu [this message]
2022-11-16 16:54   ` Mimi Zohar

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=55100c2e550b4649b5a751ca4596fe7c@huawei.com \
    --to=roberto.sassu@huawei.com \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=jmorris@namei.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=roberto.sassu@polito.it \
    --cc=serge@hallyn.com \
    --cc=xiujianfeng@huawei.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