All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mimi Zohar <zohar@linux.ibm.com>
To: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>,
	linux-integrity@vger.kernel.org
Cc: eric.snowberg@oracle.com, dhowells@redhat.com,
	mathew.j.martineau@linux.intel.com, matthewgarrett@google.com,
	sashal@kernel.org, jamorris@linux.microsoft.com,
	linux-kernel@vger.kernel.org, keyrings@vger.kernel.org
Subject: Re: [PATCH v10 6/6] IMA: Read keyrings= option from the IMA policy
Date: Tue, 10 Dec 2019 22:43:53 +0000	[thread overview]
Message-ID: <1576017833.4579.45.camel@linux.ibm.com> (raw)
In-Reply-To: <20191204224131.3384-7-nramas@linux.microsoft.com>

On Wed, 2019-12-04 at 14:41 -0800, Lakshmi Ramasubramanian wrote:
> Read "keyrings=" option, if specified in the IMA policy, and store in
> the list of IMA rules when the configured IMA policy is read.
> 
> This patch defines a new policy token enum namely Opt_keyrings
> and an option flag IMA_KEYRINGS for reading "keyrings=" option
> from the IMA policy.
> 
> Updated ima_parse_rule() to parse "keyrings=" option in the policy.
> Updated ima_policy_show() to display "keyrings=" option.
> 
> The following example illustrates how key measurement can be verified.
> 
> Sample "key" measurement rule in the IMA policy:
> 
> measure func=KEY_CHECK uid=0 keyrings=.ima|.evm template=ima-buf
> 
> Display "key" measurement in the IMA measurement list:
> 
> cat /sys/kernel/security/ima/ascii_runtime_measurements
> 
> 10 faf3...e702 ima-buf
> sha256:27c915b8ddb9fae7214cf0a8a7043cc3eeeaa7539bcb136f8427067b5f6c3
> b7b .ima 308202863082...4aee
> 
> Verify "key" measurement data for a key added to ".ima" keyring:
> 
> cat /sys/kernel/security/integrity/ima/ascii_runtime_measurements |
> grep ".ima" | cut -d' ' -f 6 | xxd -r -p |tee ima-cert.der |
> sha256sum | cut -d' ' -f 1
> 

The dot needs to be quoted, otherwise it matches any character.  I
would also limit the above command to the first instance (eg. grep -m
1 "\.ima).

> The output of the above command should match the sha256 hash
> in the "key" measurement entry in the IMA measurement list.

There are multiple hashes in a measurement list record.  Perhaps refer
to the 2nd hash as the "template hash".

Mimi

> 
> The file namely "ima-cert.der" generated by the above command
> should be a valid x509 certificate (in DER format) and should match
> the one that was used to import the key to the .ima keyring.
> The certificate file can be verified using openssl tool.
> 
> Signed-off-by: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>

WARNING: multiple messages have this Message-ID (diff)
From: Mimi Zohar <zohar@linux.ibm.com>
To: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>,
	linux-integrity@vger.kernel.org
Cc: eric.snowberg@oracle.com, dhowells@redhat.com,
	mathew.j.martineau@linux.intel.com, matthewgarrett@google.com,
	sashal@kernel.org, jamorris@linux.microsoft.com,
	linux-kernel@vger.kernel.org, keyrings@vger.kernel.org
Subject: Re: [PATCH v10 6/6] IMA: Read keyrings= option from the IMA policy
Date: Tue, 10 Dec 2019 17:43:53 -0500	[thread overview]
Message-ID: <1576017833.4579.45.camel@linux.ibm.com> (raw)
In-Reply-To: <20191204224131.3384-7-nramas@linux.microsoft.com>

On Wed, 2019-12-04 at 14:41 -0800, Lakshmi Ramasubramanian wrote:
> Read "keyrings=" option, if specified in the IMA policy, and store in
> the list of IMA rules when the configured IMA policy is read.
> 
> This patch defines a new policy token enum namely Opt_keyrings
> and an option flag IMA_KEYRINGS for reading "keyrings=" option
> from the IMA policy.
> 
> Updated ima_parse_rule() to parse "keyrings=" option in the policy.
> Updated ima_policy_show() to display "keyrings=" option.
> 
> The following example illustrates how key measurement can be verified.
> 
> Sample "key" measurement rule in the IMA policy:
> 
> measure func=KEY_CHECK uid=0 keyrings=.ima|.evm template=ima-buf
> 
> Display "key" measurement in the IMA measurement list:
> 
> cat /sys/kernel/security/ima/ascii_runtime_measurements
> 
> 10 faf3...e702 ima-buf
> sha256:27c915b8ddb9fae7214cf0a8a7043cc3eeeaa7539bcb136f8427067b5f6c3
> b7b .ima 308202863082...4aee
> 
> Verify "key" measurement data for a key added to ".ima" keyring:
> 
> cat /sys/kernel/security/integrity/ima/ascii_runtime_measurements |
> grep ".ima" | cut -d' ' -f 6 | xxd -r -p |tee ima-cert.der |
> sha256sum | cut -d' ' -f 1
> 

The dot needs to be quoted, otherwise it matches any character.  I
would also limit the above command to the first instance (eg. grep -m
1 "\.ima).

> The output of the above command should match the sha256 hash
> in the "key" measurement entry in the IMA measurement list.

There are multiple hashes in a measurement list record.  Perhaps refer
to the 2nd hash as the "template hash".

Mimi

> 
> The file namely "ima-cert.der" generated by the above command
> should be a valid x509 certificate (in DER format) and should match
> the one that was used to import the key to the .ima keyring.
> The certificate file can be verified using openssl tool.
> 
> Signed-off-by: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>


  reply	other threads:[~2019-12-10 22:43 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-04 22:41 [PATCH v10 0/6] KEYS: Measure keys when they are created or updated Lakshmi Ramasubramanian
2019-12-04 22:41 ` Lakshmi Ramasubramanian
2019-12-04 22:41 ` [PATCH v10 1/6] IMA: Check IMA policy flag Lakshmi Ramasubramanian
2019-12-04 22:41   ` Lakshmi Ramasubramanian
2019-12-10 22:42   ` Mimi Zohar
2019-12-10 22:42     ` Mimi Zohar
2019-12-10 23:29     ` Lakshmi Ramasubramanian
2019-12-10 23:29       ` Lakshmi Ramasubramanian
2019-12-11  0:03       ` Mimi Zohar
2019-12-11  0:03         ` Mimi Zohar
2019-12-04 22:41 ` [PATCH v10 2/6] IMA: Add KEY_CHECK func to measure keys Lakshmi Ramasubramanian
2019-12-04 22:41   ` Lakshmi Ramasubramanian
2019-12-04 22:41 ` [PATCH v10 3/6] IMA: Define an IMA hook " Lakshmi Ramasubramanian
2019-12-04 22:41   ` Lakshmi Ramasubramanian
2019-12-10 22:42   ` Mimi Zohar
2019-12-10 22:42     ` Mimi Zohar
2019-12-04 22:41 ` [PATCH v10 4/6] KEYS: Call the " Lakshmi Ramasubramanian
2019-12-04 22:41   ` Lakshmi Ramasubramanian
2019-12-10 22:43   ` Mimi Zohar
2019-12-10 22:43     ` Mimi Zohar
2019-12-04 22:41 ` [PATCH v10 5/6] IMA: Add support to limit measuring keys Lakshmi Ramasubramanian
2019-12-04 22:41   ` Lakshmi Ramasubramanian
2019-12-10 22:43   ` Mimi Zohar
2019-12-10 22:43     ` Mimi Zohar
2019-12-10 23:23     ` Lakshmi Ramasubramanian
2019-12-10 23:23       ` Lakshmi Ramasubramanian
2019-12-04 22:41 ` [PATCH v10 6/6] IMA: Read keyrings= option from the IMA policy Lakshmi Ramasubramanian
2019-12-04 22:41   ` Lakshmi Ramasubramanian
2019-12-10 22:43   ` Mimi Zohar [this message]
2019-12-10 22:43     ` 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=1576017833.4579.45.camel@linux.ibm.com \
    --to=zohar@linux.ibm.com \
    --cc=dhowells@redhat.com \
    --cc=eric.snowberg@oracle.com \
    --cc=jamorris@linux.microsoft.com \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathew.j.martineau@linux.intel.com \
    --cc=matthewgarrett@google.com \
    --cc=nramas@linux.microsoft.com \
    --cc=sashal@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 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.