public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>
To: zohar@linux.ibm.com
Cc: tyhicks@linux.microsoft.com, tusharsu@linux.microsoft.com,
	sashal@kernel.org, linux-integrity@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v3 3/3] IMA: Support early boot measurement of critical data
Date: Sat, 26 Sep 2020 08:52:19 -0700	[thread overview]
Message-ID: <20200926155219.5561-4-nramas@linux.microsoft.com> (raw)
In-Reply-To: <20200926155219.5561-1-nramas@linux.microsoft.com>

The IMA hook ima_measure_critical_data() requires a custom IMA policy
to be loaded to determine what data should be measured by IMA.
If a custom policy is not loaded by the time ima_measure_critical_data()
is called, then IMA needs to queue the data until a policy is loaded.

Update ima_measure_critical_data() to utilize early boot measurement
support to defer processing data if a custom IMA policy is not yet
loaded.

Signed-off-by: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>
---
 security/integrity/ima/ima_main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 438199e43f5e..5162917e6bf2 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -898,6 +898,8 @@ void ima_measure_critical_data(const char *event_name,
 			       const void *buf, int buf_len,
 			       bool measure_buf_hash)
 {
+	bool queued = false;
+
 	if (!event_name || !event_data_source || !buf || !buf_len) {
 		pr_err("Invalid arguments passed to %s().\n", __func__);
 		return;
@@ -909,6 +911,14 @@ void ima_measure_critical_data(const char *event_name,
 		return;
 	}
 
+	if (ima_should_queue_data())
+		queued = ima_queue_data(event_name, buf, buf_len,
+					event_data_source, CRITICAL_DATA,
+					measure_buf_hash);
+
+	if (queued)
+		return;
+
 	process_buffer_measurement(NULL, buf, buf_len, event_name,
 				   CRITICAL_DATA, 0, event_data_source,
 				   measure_buf_hash);
-- 
2.28.0


      parent reply	other threads:[~2020-09-26 15:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-26 15:52 [PATCH v3 0/3] IMA: Generalize early boot data measurement Lakshmi Ramasubramanian
2020-09-26 15:52 ` [PATCH v3 1/3] IMA: Generalize early boot measurement of asymmetric keys Lakshmi Ramasubramanian
2020-09-26 15:52 ` [PATCH v3 2/3] IMA: Support measurement of generic data during early Lakshmi Ramasubramanian
2020-09-26 15:52 ` Lakshmi Ramasubramanian [this message]

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=20200926155219.5561-4-nramas@linux.microsoft.com \
    --to=nramas@linux.microsoft.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=tusharsu@linux.microsoft.com \
    --cc=tyhicks@linux.microsoft.com \
    --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