From: Mimi Zohar <zohar@linux.ibm.com>
To: Matthew Garrett <matthewgarrett@google.com>,
linux-integrity@vger.kernel.org
Cc: prsriva02@gmail.com, bauerman@linux.ibm.com,
roberto.sassu@huawei.com, Matthew Garrett <mjg59@google.com>
Subject: Re: [PATCH V3] IMA: Allow profiles to define the desired IMA template
Date: Tue, 04 Jun 2019 09:52:06 -0400 [thread overview]
Message-ID: <1559656326.4056.5.camel@linux.ibm.com> (raw)
In-Reply-To: <1559613113.3956.9.camel@linux.ibm.com>
On Mon, 2019-06-03 at 21:51 -0400, Mimi Zohar wrote:
> On Mon, 2019-06-03 at 13:13 -0700, Matthew Garrett wrote:
> > Admins may wish to log different measurements using different IMA
> > templates. Add support for overriding the default template on a per-rule
> > basis.
> >
> > Signed-off-by: Matthew Garrett <mjg59@google.com>
> > ---
> >
> > Updated based on review feedback, verified that I can generate an event
> > log that contains multiple different templates.
> >
> > Documentation/ABI/testing/ima_policy | 6 ++++--
> > security/integrity/ima/ima.h | 13 +++++++++----
> > security/integrity/ima/ima_api.c | 24 ++++++++++++++++-------
> > security/integrity/ima/ima_appraise.c | 2 +-
> > security/integrity/ima/ima_init.c | 2 +-
> > security/integrity/ima/ima_main.c | 9 +++++----
> > security/integrity/ima/ima_policy.c | 28 +++++++++++++++++++++++++--
> > security/integrity/ima/ima_template.c | 10 ++++++++--
> > 8 files changed, 71 insertions(+), 23 deletions(-)
> >
> > diff --git a/Documentation/ABI/testing/ima_policy b/Documentation/ABI/testing/ima_policy
> > index 74c6702de74e..4ded0668a22d 100644
> > --- a/Documentation/ABI/testing/ima_policy
> > +++ b/Documentation/ABI/testing/ima_policy
> > @@ -24,8 +24,7 @@ Description:
> > [euid=] [fowner=] [fsname=]]
> > lsm: [[subj_user=] [subj_role=] [subj_type=]
> > [obj_user=] [obj_role=] [obj_type=]]
> > - option: [[appraise_type=]] [permit_directio]
> > -
> > + option: [[appraise_type=]] [template=] [permit_directio]
> > base: func:= [BPRM_CHECK][MMAP_CHECK][CREDS_CHECK][FILE_CHECK][MODULE_CHECK]
> > [FIRMWARE_CHECK]
> > [KEXEC_KERNEL_CHECK] [KEXEC_INITRAMFS_CHECK]
> > @@ -38,6 +37,9 @@ Description:
> > fowner:= decimal value
> > lsm: are LSM specific
> > option: appraise_type:= [imasig]
> > + template:= name or format of a defined IMA template
> > + type (eg,ima-ng or d-ng|n-ng). Only valid when action
> > + is "measure".
>
> This patch only supports specifying the template name, not the
> template format description. Please remove "d-ng|n-ng".
>
> > pcr:= decimal value
> >
> > default policy:
>
> <snip>
>
> > diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
> > index 0f6fe53cef09..cbae2a3a9c5b 100644
> > --- a/security/integrity/ima/ima_policy.c
> > +++ b/security/integrity/ima/ima_policy.c
> > @@ -80,6 +80,7 @@ struct ima_rule_entry {
> > int type; /* audit type */
> > } lsm[MAX_LSM_RULES];
> > char *fsname;
> > + struct ima_template_desc *template;
> > };
> >
> > /*
> > @@ -397,6 +398,7 @@ static int get_subaction(struct ima_rule_entry *rule, enum ima_hooks func)
> > * @func: IMA hook identifier
> > * @mask: requested action (MAY_READ | MAY_WRITE | MAY_APPEND | MAY_EXEC)
> > * @pcr: set the pcr to extend
> > + * @template_desc: the template that should be used for this rule
> > *
> > * Measure decision based on func/mask/fsmagic and LSM(subj/obj/type)
> > * conditions.
> > @@ -406,7 +408,8 @@ static int get_subaction(struct ima_rule_entry *rule, enum ima_hooks func)
> > * than writes so ima_match_policy() is classical RCU candidate.
> > */
> > int ima_match_policy(struct inode *inode, const struct cred *cred, u32 secid,
> > - enum ima_hooks func, int mask, int flags, int *pcr)
> > + enum ima_hooks func, int mask, int flags, int *pcr,
> > + struct ima_template_desc **template_desc)
> > {
> > struct ima_rule_entry *entry;
> > int action = 0, actmask = flags | (flags << 1);
> > @@ -438,6 +441,11 @@ int ima_match_policy(struct inode *inode, const struct cred *cred, u32 secid,
> > if ((pcr) && (entry->flags & IMA_PCR))
> > *pcr = entry->pcr;
> >
> > + if (template_desc && entry->template)
> > + *template_desc = entry->template;
> > + else
> > + *template_desc = ima_template_desc_current();
> > +
>
> This code is finding the template format, but is subsequently being
> replaced with the current description. One way of fixing this, is by
> initializing the template_desc before walking the list.
Perhaps not, but the "else" clause also needs to test template_desc.
The other option is for all ima_match_policy callers to provide
template_desc.
Mimi
>
> > if (!actmask)
> > break;
> > }
> > @@ -676,7 +684,7 @@ enum {
> > Opt_uid_gt, Opt_euid_gt, Opt_fowner_gt,
> > Opt_uid_lt, Opt_euid_lt, Opt_fowner_lt,
> > Opt_appraise_type, Opt_permit_directio,
> > - Opt_pcr, Opt_err
> > + Opt_pcr, Opt_template, Opt_err
> > };
> >
next prev parent reply other threads:[~2019-06-04 13:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-03 20:13 [PATCH V3] IMA: Allow profiles to define the desired IMA template Matthew Garrett
2019-06-04 1:51 ` Mimi Zohar
2019-06-04 13:52 ` Mimi Zohar [this message]
2019-06-04 14:03 ` Roberto Sassu
2019-06-04 14:32 ` Mimi Zohar
2019-06-04 14:40 ` Roberto Sassu
2019-06-04 14:47 ` Mimi Zohar
2019-06-04 14:49 ` Roberto Sassu
2019-06-04 20:03 ` Matthew Garrett
2019-06-04 20:16 ` Mimi Zohar
2019-06-04 14:29 ` Roberto Sassu
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=1559656326.4056.5.camel@linux.ibm.com \
--to=zohar@linux.ibm.com \
--cc=bauerman@linux.ibm.com \
--cc=linux-integrity@vger.kernel.org \
--cc=matthewgarrett@google.com \
--cc=mjg59@google.com \
--cc=prsriva02@gmail.com \
--cc=roberto.sassu@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.