Skip to content

Commit 450d0fd

Browse files
nramasmimizohar
authored andcommitted
IMA: Call workqueue functions to measure queued keys
Measuring keys requires a custom IMA policy to be loaded. Keys should be queued for measurement if a custom IMA policy is not yet loaded. Keys queued for measurement, if any, should be processed when a custom policy is loaded. This patch updates the IMA hook function ima_post_key_create_or_update() to queue the key if a custom IMA policy has not yet been loaded. And, ima_update_policy() function, which is called when a custom IMA policy is loaded, is updated to process queued keys. Signed-off-by: Lakshmi Ramasubramanian <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent 9f81a2e commit 450d0fd

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

security/integrity/ima/ima_asymmetric_keys.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,21 @@ void ima_post_key_create_or_update(struct key *keyring, struct key *key,
3030
const void *payload, size_t payload_len,
3131
unsigned long flags, bool create)
3232
{
33+
bool queued = false;
34+
3335
/* Only asymmetric keys are handled by this hook. */
3436
if (key->type != &key_type_asymmetric)
3537
return;
3638

3739
if (!payload || (payload_len == 0))
3840
return;
3941

42+
if (ima_should_queue_key())
43+
queued = ima_queue_key(keyring, payload, payload_len);
44+
45+
if (queued)
46+
return;
47+
4048
/*
4149
* keyring->description points to the name of the keyring
4250
* (such as ".builtin_trusted_keys", ".ima", etc.) to

security/integrity/ima/ima_policy.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,9 @@ void ima_update_policy(void)
809809
kfree(arch_policy_entry);
810810
}
811811
ima_update_policy_flag();
812+
813+
/* Custom IMA policy has been loaded */
814+
ima_process_queued_keys();
812815
}
813816

814817
/* Keep the enumeration in sync with the policy_tokens! */

0 commit comments

Comments
 (0)