From: Mimi Zohar <zohar@linux.ibm.com>
To: GUO Zihua <guozihua@huawei.com>,
stable@vger.kernel.org, gregkh@linuxfoundation.org
Cc: paul@paul-moore.com, linux-integrity@vger.kernel.org,
luhuaxin1@huawei.com
Subject: Re: [PATCH v6 2/3] ima: use the lsm policy update notifier
Date: Thu, 05 Jan 2023 12:35:07 -0500 [thread overview]
Message-ID: <d11ea8036738664ec7a796d56b38f63ce0b64ae5.camel@linux.ibm.com> (raw)
In-Reply-To: <20230105062312.14325-3-guozihua@huawei.com>
> +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;
> +
> + /*
> + * Immutable elements are copied over as pointers and data; only
> + * lsm rules can change
> + */
> + memcpy(nentry, entry, sizeof(*nentry));
> + memset(nentry->lsm, 0, FIELD_SIZEOF(struct ima_rule_entry, lsm));
> +
> for (i = 0; i < MAX_LSM_RULES; i++) {
> - security_filter_rule_free(entry->lsm[i].rule);
> - kfree(entry->lsm[i].args_p);
> + if (!entry->lsm[i].rule)
> + continue;
> +
> + 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;
> +
> + result = security_filter_rule_init(nentry->lsm[i].type,
> + Audit_equal,
> + nentry->lsm[i].args_p,
> + &nentry->lsm[i].rule);
> + if (result == -EINVAL)
> + pr_warn("ima: rule for LSM \'%d\' is undefined\n",
> + entry->lsm[i].type);
> }
> + return nentry;
> +
> +out_err:
> + ima_lsm_free_rule(entry);
> kfree(entry);
This should be "nentry". Otherwise, it looks good.
thanks,
Mimi
> + return NULL;
> +}
next prev parent reply other threads:[~2023-01-05 17:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-05 6:23 [PATCH v6 0/3] ima: Fix IMA mishandling of LSM based rule during GUO Zihua
2023-01-05 6:23 ` [PATCH v6 1/3] LSM: switch to blocking policy update notifiers GUO Zihua
2023-01-05 6:23 ` [PATCH v6 2/3] ima: use the lsm policy update notifier GUO Zihua
2023-01-05 17:35 ` Mimi Zohar [this message]
2023-01-05 6:23 ` [PATCH v6 3/3] ima: Handle -ESTALE returned by ima_filter_rule_match() GUO Zihua
2023-01-05 11:47 ` [PATCH v6 0/3] ima: Fix IMA mishandling of LSM based rule during Greg KH
2023-01-10 13:30 ` 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=d11ea8036738664ec7a796d56b38f63ce0b64ae5.camel@linux.ibm.com \
--to=zohar@linux.ibm.com \
--cc=gregkh@linuxfoundation.org \
--cc=guozihua@huawei.com \
--cc=linux-integrity@vger.kernel.org \
--cc=luhuaxin1@huawei.com \
--cc=paul@paul-moore.com \
--cc=stable@vger.kernel.org \
/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