From: Roberto Sassu <roberto.sassu@huaweicloud.com>
To: Mimi Zohar <zohar@linux.ibm.com>,
corbet@lwn.net, dmitry.kasatkin@gmail.com,
eric.snowberg@oracle.com, paul@paul-moore.com,
jmorris@namei.org, serge@hallyn.com
Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-integrity@vger.kernel.org,
linux-security-module@vger.kernel.org,
wufan@linux.microsoft.com, pbrobinson@gmail.com,
zbyszek@in.waw.pl, hch@lst.de, mjg59@srcf.ucam.org,
pmatilai@redhat.com, jannh@google.com, dhowells@redhat.com,
jikos@kernel.org, mkoutny@suse.com, ppavlu@suse.com,
petr.vorel@gmail.com, petrtesarik@huaweicloud.com,
mzerqung@0pointer.de, kgold@linux.ibm.com,
Roberto Sassu <roberto.sassu@huawei.com>
Subject: Re: [RFC][PATCH 4/8] ima: Add digest_cache_measure and digest_cache_appraise boot-time policies
Date: Fri, 08 Mar 2024 11:36:48 +0100 [thread overview]
Message-ID: <e10207bd82ee13fb088f9efc12e10a5478b6926d.camel@huaweicloud.com> (raw)
In-Reply-To: <ed5df367582f0c5e212638a12204fd20fd8e46e5.camel@linux.ibm.com>
On Thu, 2024-03-07 at 15:17 -0500, Mimi Zohar wrote:
> On Wed, 2024-02-14 at 15:35 +0100, Roberto Sassu wrote:
> > From: Roberto Sassu <roberto.sassu@huawei.com>
> >
> > Specify the 'digest_cache_measure' boot-time policy with 'ima_policy=' in
> > the kernel command line
>
> The 'built-in' policies may be specified on the boot command line. Please
> update Subject line, to user the term "built-in" as well as here.
Ok, will do.
> > to add the following rule at the beginning of the
> > IMA policy, before other rules:
>
> Comments below...
>
> >
> > measure func=DIGEST_LIST_CHECK pcr=12
> >
> > which will measure digest lists into PCR 12 (or the value in
> > CONFIG_IMA_DIGEST_CACHE_MEASURE_PCR_IDX).
> >
> > 'digest_cache_measure' also adds 'digest_cache=content pcr=12' to the other
> > measure rules, if they have a compatible IMA hook. The PCR value still
> > comes from CONFIG_IMA_DIGEST_CACHE_MEASURE_PCR_IDX.
> >
> > Specify 'digest_cache_appraise' to add the following rule at the beginning,
> > before other rules:
> >
> > appraise func=DIGEST_LIST_CHECK appraise_type=imasig|modsig
> >
> > which will appraise digest lists with IMA signatures or module-style
> > appended signatures.
> >
> > 'digest_cache_appraise' also adds 'digest_cache=content' to the other
> > appraise rules, if they have a compatible IMA hook.
> >
> > Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
> > ---
> > .../admin-guide/kernel-parameters.txt | 15 ++++++-
> > security/integrity/ima/Kconfig | 10 +++++
> > security/integrity/ima/ima_policy.c | 45 +++++++++++++++++++
> > 3 files changed, 69 insertions(+), 1 deletion(-)
>
> [...]
>
> > @@ -971,6 +1006,16 @@ void __init ima_init_policy(void)
> > {
> > int build_appraise_entries, arch_entries;
> >
> > + /*
> > + * We need to load digest cache rules at the beginning, to avoid dont_
> > + * rules causing ours to not be reached.
> > + */
>
> "lockdown" trusts IMA to measure and appraise kernel modules, if the rule
> exists. Placing the digest_cache first breaks this trust.
The new rules don't prevent other rules to be reached, since they are
'do' and not 'don_t' rules.
If the kernel reads a file with file ID READING_MODULE, that would
still be matched by rules with 'func=MODULE_CHECK', even if there are
rules with 'func=DIGEST_LIST_CHECK', which will be instead matched when
there is a kernel read with file ID READING_DIGEST_LIST.
We can talk about the rule modification. Speaking of appraising kernel
modules, setting 'ima_policy=digest_cache_appraise' in the kernel
command line would have the effect of changing:
appraise func=MODULE_CHECK appraise_type=imasig|modsig
to:
appraise func=DIGEST_LIST_CHECK appraise_type=imasig|modsig
appraise func=MODULE_CHECK appraise_type=imasig|modsig digest_cache=content
The effect of this would be that, if the kernel does not have
security.ima or an appended signature, appraisal will be still
successful by verifying the signature (in the xattr or appended) of the
digest list, and looking up the digest of the kernel module in that
digest list.
> From a trusted and secure boot perspective, the architecture specific policy
> rules should not be ignored.
I'm still missing how the architecture-specific policy would be
ignored.
> Putting the digest_cache before any other rules
> will limit others from being able to use digest_cache.
Sorry, didn't understand.
Let me just remark that measuring/appraising a digest list is a
necessary condition for using the digest cache built from that digest
list.
Not doing that has the same effect of a negative digest lookup, even if
that digest was in the digest list.
> Instead of putting the digest_cache_{measure,appraise} built-in policies first,
> skip loading the dont_measure_rules.
It does not seem a good idea. We still want to avoid
measurements/appraisal in the pseudo filesystems.
Roberto
> Mimi
>
> > + if (ima_digest_cache_measure)
> > + add_rules(&measure_digest_cache_rule, 1, IMA_DEFAULT_POLICY);
> > +
> > + if (ima_digest_cache_appraise)
> > + add_rules(&appraise_digest_cache_rule, 1, IMA_DEFAULT_POLICY);
> > +
> > /* if !ima_policy, we load NO default rules */
> > if (ima_policy)
> > add_rules(dont_measure_rules, ARRAY_SIZE(dont_measure_rules),
next prev parent reply other threads:[~2024-03-08 10:37 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-14 14:35 [RFC][PATCH 0/8] ima: Integrate with digest_cache LSM Roberto Sassu
2024-02-14 14:35 ` [RFC][PATCH 1/8] ima: Introduce hook DIGEST_LIST_CHECK Roberto Sassu
2024-02-14 14:35 ` [RFC][PATCH 2/8] ima: Nest iint mutex for DIGEST_LIST_CHECK hook Roberto Sassu
2024-03-07 19:42 ` Mimi Zohar
2024-03-08 8:00 ` Roberto Sassu
2024-02-14 14:35 ` [RFC][PATCH 3/8] ima: Add digest_cache policy keyword Roberto Sassu
2024-03-07 19:43 ` Mimi Zohar
2024-03-08 9:05 ` Roberto Sassu
2024-03-08 13:41 ` Mimi Zohar
2024-02-14 14:35 ` [RFC][PATCH 4/8] ima: Add digest_cache_measure and digest_cache_appraise boot-time policies Roberto Sassu
2024-03-07 20:17 ` Mimi Zohar
2024-03-08 10:36 ` Roberto Sassu [this message]
2024-03-08 14:23 ` Mimi Zohar
2024-03-11 13:01 ` Mimi Zohar
2024-02-14 14:35 ` [RFC][PATCH 5/8] ima: Record IMA verification result of digest lists in digest cache Roberto Sassu
2024-03-11 14:00 ` Mimi Zohar
2024-02-14 14:35 ` [RFC][PATCH 6/8] ima: Use digest cache for measurement Roberto Sassu
2024-03-08 16:08 ` Mimi Zohar
2024-03-08 16:27 ` Roberto Sassu
2024-02-14 14:35 ` [RFC][PATCH 7/8] ima: Use digest cache for appraisal Roberto Sassu
2024-02-14 14:35 ` [RFC][PATCH 8/8] ima: Detect if digest cache changed since last measurement/appraisal Roberto Sassu
2024-03-08 17:35 ` Mimi Zohar
2024-03-11 9:11 ` Roberto Sassu
2024-03-11 12:19 ` 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=e10207bd82ee13fb088f9efc12e10a5478b6926d.camel@huaweicloud.com \
--to=roberto.sassu@huaweicloud.com \
--cc=corbet@lwn.net \
--cc=dhowells@redhat.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=eric.snowberg@oracle.com \
--cc=hch@lst.de \
--cc=jannh@google.com \
--cc=jikos@kernel.org \
--cc=jmorris@namei.org \
--cc=kgold@linux.ibm.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mjg59@srcf.ucam.org \
--cc=mkoutny@suse.com \
--cc=mzerqung@0pointer.de \
--cc=paul@paul-moore.com \
--cc=pbrobinson@gmail.com \
--cc=petr.vorel@gmail.com \
--cc=petrtesarik@huaweicloud.com \
--cc=pmatilai@redhat.com \
--cc=ppavlu@suse.com \
--cc=roberto.sassu@huawei.com \
--cc=serge@hallyn.com \
--cc=wufan@linux.microsoft.com \
--cc=zbyszek@in.waw.pl \
--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