From: Mimi Zohar <zohar@linux.ibm.com>
To: Colin Ian King <colin.king@canonical.com>,
Joe Perches <joe@perches.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-security-module@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ima: Fix sizeof mismatches
Date: Tue, 13 Oct 2020 12:17:37 -0400 [thread overview]
Message-ID: <ba5f4d90c714eba5d5a1d822bca25305b40a73e1.camel@linux.ibm.com> (raw)
In-Reply-To: <0ceb198a-a313-f542-49cc-c0b9f6b1ea52@canonical.com>
On Mon, 2020-10-12 at 19:10 +0100, Colin Ian King wrote:
> On 12/10/2020 19:06, Joe Perches wrote:
> > On Mon, 2020-10-12 at 13:51 -0400, Mimi Zohar wrote:
> >> On Wed, 2020-10-07 at 11:27 -0700, Joe Perches wrote:
> >>> 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...
> >>>
> >>
> >> Thanks, Joe. Since this patch will be backported, perhaps it would be
> >> better to leave this as a bug fix and upstream other changes
> >> independently.
> >
> > IMO:
> >
> > This patch doesn't need need backporting as it doesn't
> > actually fix anything other than a style defect.
> >
> > void * and void ** are the same size.
>
> indeed, same size, it's a semantic difference *and* a style fix :-)
Colin, based on Joe's suggestion of using kmemdup and his opinion of
not backporting this change, can I assume you'll address his comments
and re-post v3?
thanks,
Mimi
next prev parent reply other threads:[~2020-10-13 16:17 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
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 [this message]
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=ba5f4d90c714eba5d5a1d822bca25305b40a73e1.camel@linux.ibm.com \
--to=zohar@linux.ibm.com \
--cc=colin.king@canonical.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=jmorris@namei.org \
--cc=joe@perches.com \
--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 \
/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;
as well as URLs for NNTP newsgroup(s).