Linux Documentation
 help / color / mirror / Atom feed
From: Mimi Zohar <zohar@linux.ibm.com>
To: Roberto Sassu <roberto.sassu@huaweicloud.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 3/8] ima: Add digest_cache policy keyword
Date: Fri, 08 Mar 2024 08:41:27 -0500	[thread overview]
Message-ID: <3e855b6c0892a00743758fc04bfb183cae2a42ef.camel@linux.ibm.com> (raw)
In-Reply-To: <71c77bbef487ae3279f0c3f85785bd0c03a4ee8c.camel@huaweicloud.com>

On Fri, 2024-03-08 at 10:05 +0100, Roberto Sassu wrote:
> On Thu, 2024-03-07 at 14:43 -0500, Mimi Zohar wrote:
> > On Wed, 2024-02-14 at 15:35 +0100, Roberto Sassu wrote:
> > > From: Roberto Sassu <roberto.sassu@huawei.com>
> > > 
> > > Add the 'digest_cache=' policy keyword, to enable the usage of digest
> > > caches for specific IMA actions and purposes.
> > > 
> > > At the moment, it accepts only 'content' as value, as digest caches can be
> > > only used only for measurement and appraisal of file content. In the
> > > future, it might be possible to use them for file metadata too.
> > 
> > At least from this patch, it is unclear why 'digest_cache' requires an
> > option.  
> > The usage - measure, appraise - is based on 'action'.  From an IMA
> > perspective,
> > does the file content make a difference?  And if it did, then file 'data'
> > would
> > parallel file 'metadata'.
> 
> I wanted to express the fact that digest caches, if available, can only
> be used to appraise file data, if there is no metadata (similarly to
> module-style appended signatures).
> 
> That would prevent for example the scenario where appraisal of file
> data is successful without having verified current metadata, and EVM
> attaches to the file a valid HMAC on file close, based on the current
> xattr value (trust at first use).

Correct. There's no requirement for 'security.ima' to exist to calculate the EVM
HMAC.  Before using EVM HMAC, the filesystem needs to be properly labeled by
walking the filesystem.  The HMAC is calculated based on the existing file
metadata.  The first use is during a setup stage and subsequently for new files.

> 
> An IMA rule with 'digest_cache=metadata' would take a different code
> path. It would make IMA send to evm_verifyxattr() the calculated file
> digest (since there is no security.ima), and let EVM calculate and
> search the digest of file metadata in the digest cache.

Ok.  So no 'security.evm' either, but a metadata digest cache.

I understand the need to provide EVM with the file hash in this case, but as
much as possible, IMA and EVM should be independent of each other.

> 
> I didn't go that far yet, but this is more or less what I would like to
> do, also based on my old implementation of the IMA Digest Lists
> extension (which supports file metadata lookup).
> 
> > Without having to pass around "digest_cache_mask" would simplify this patch.
> 
> We need to pass it anyway, to let process_measurement() know that it
> can use digest caches. Or we can make 'flags' in ima_iint_cache a u64,
> and introduce new flags.

It's bad enough that the function parameters change when there's actual data. 
Yes, please increase the size of 'flags' and introduce new flags.

thanks,

Mimi

> > > The 'digest_cache=' keyword can be specified for the subset of IMA hooks
> > > listed in ima_digest_cache_func_allowed().
> > > 
> > > POLICY_CHECK has been excluded for measurement, because policy changes
> > > must
> > > be visible in the IMA measurement list. For appraisal, instead, it might
> > > be
> > > useful to load custom policies in the initial ram disk (no security.ima
> > > xattr).
> > > 
> > > Add the digest_cache_mask member to the ima_rule_entry structure, and set
> > > the flag IMA_DIGEST_CACHE_MEASURE_CONTENT if 'digest_cache=content' was
> > > specified for a measure rule, IMA_DIGEST_CACHE_APPRAISE_CONTENT for an
> > > appraise rule.
> > > 
> > > Propagate the mask down to ima_match_policy() and ima_get_action(), so
> > > that
> > > process_measurement() can make the final decision on whether or not digest
> > > caches should be used to measure/appraise the file being evaluated.
> > > 
> > > Since using digest caches changes the meaning of the IMA measurement list,
> > > which will include only digest lists and unknown files, enforce specifying
> > > 'pcr=' with a non-standard value, when 'digest_cache=content' is specified
> > > in a measure rule.
> > > 
> > > This removes the ambiguity on the meaning of the IMA measurement list.
> > > 
> > > Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
> > > 


  reply	other threads:[~2024-03-08 13:46 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 [this message]
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
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=3e855b6c0892a00743758fc04bfb183cae2a42ef.camel@linux.ibm.com \
    --to=zohar@linux.ibm.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=roberto.sassu@huaweicloud.com \
    --cc=serge@hallyn.com \
    --cc=wufan@linux.microsoft.com \
    --cc=zbyszek@in.waw.pl \
    /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