From: Mimi Zohar <zohar@linux.ibm.com>
To: Janne Karhunen <janne.karhunen@gmail.com>,
sds@tycho.nsa.gov, paul@paul-moore.com
Cc: linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org
Subject: Re: [PATCH 2/2] ima: use the lsm policy update notifier
Date: Thu, 06 Jun 2019 18:28:04 -0400 [thread overview]
Message-ID: <1559860084.4278.173.camel@linux.ibm.com> (raw)
In-Reply-To: <1559858345.4278.163.camel@linux.ibm.com>
Hi Janne,
One more comment below ...
> > +
> > +static struct ima_rule_entry *ima_lsm_copy_rule(struct ima_rule_entry *entry)
> > +{
> > + struct ima_rule_entry *nentry;
> > + int i, result;
> > +
> > + nentry = kmalloc(sizeof(*nentry), GFP_KERNEL);
> > + if (!nentry)
> > + return NULL;
> > +
> > + memcpy(nentry, entry, sizeof(*nentry));
> > + nentry->fsname = NULL;
> > + for (i = 0; i < MAX_LSM_RULES; i++) {
> > + nentry->lsm[i].rule = NULL;
> > + nentry->lsm[i].args_p = NULL;
> > + }
I don't think this loop is necessary. Either use kzalloc() or move
the initialization to inside the loop below.
> > +
> > + if (entry->fsname) {
> > + nentry->fsname = kstrdup(entry->fsname, GFP_KERNEL);
> > + if (!nentry->fsname)
> > + goto out_err;
> > + }
> > + for (i = 0; i < MAX_LSM_RULES; i++) {
> > + if (!entry->lsm[i].rule)
> > + continue;
To here.
> > +
> > + nentry->lsm[i].type = entry->lsm[i].type;
> > + nentry->lsm[i].args_p = kstrdup(entry->lsm[i].args_p,
> > + GFP_KERNEL);
> > + if (!nentry->lsm[i].args_p)
> > + goto out_err;
If the memory allocation fails, then nentry will be freed anyway.
thanks,
Mimid
next prev parent reply other threads:[~2019-06-06 22:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-05 8:36 [PATCH 1/2] LSM: switch to blocking policy update notifiers Janne Karhunen
2019-06-05 8:36 ` [PATCH 2/2] ima: use the lsm policy update notifier Janne Karhunen
2019-06-06 21:59 ` Mimi Zohar
2019-06-06 22:28 ` Mimi Zohar [this message]
2019-06-05 15:23 ` [PATCH 1/2] LSM: switch to blocking policy update notifiers Casey Schaufler
2019-06-05 16:51 ` Janne Karhunen
2019-06-05 17:05 ` Casey Schaufler
2019-06-05 19:14 ` Paul Moore
2019-06-07 0:45 ` James Morris
2019-06-07 5:19 ` Paul Moore
2019-06-07 21:48 ` James Morris
2019-06-09 17:06 ` Janne Karhunen
2019-06-05 19:15 ` Paul Moore
-- strict thread matches above, loose matches on Subject: below --
2019-05-31 14:02 Janne Karhunen
2019-05-31 14:02 ` [PATCH 2/2] ima: use the lsm policy update notifier Janne Karhunen
2019-05-31 18:35 ` Stephen Smalley
2019-06-03 6:58 ` Janne Karhunen
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=1559860084.4278.173.camel@linux.ibm.com \
--to=zohar@linux.ibm.com \
--cc=janne.karhunen@gmail.com \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=sds@tycho.nsa.gov \
/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).