[PATCH v3 3/3] IMA: Support early boot measurement of critical data
From: Lakshmi Ramasubramanian
Date: Sat Sep 26 2020 - 11:52:28 EST
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@xxxxxxxxxxxxxxxxxxx>
---
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