lkml.org 
[lkml]   [2020]   [Jan]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: inconsistent lock state in ima_process_queued_keys
From
Date
Hi Dmitry,

> --- a/security/integrity/ima/ima_asymmetric_keys.c
> +++ b/security/integrity/ima/ima_asymmetric_keys.c
> @@ -103,17 +103,18 @@ static bool ima_queue_key(struct key *keyring,
> const void *payload,
> {
> bool queued = false;
> struct ima_key_entry *entry;
> + unsigned long flags;
>
> entry = ima_alloc_key_entry(keyring, payload, payload_len);
> if (!entry)
> return false;
>
> - spin_lock(&ima_keys_lock);
> + spin_lock_irqsave(&ima_keys_lock, flags);
> if (!ima_process_keys) {
> list_add_tail(&entry->list, &ima_keys);
> queued = true;
> }
> - spin_unlock(&ima_keys_lock);
> + spin_unlock_irqrestore(&ima_keys_lock, flags);
>
> if (!queued)
> ima_free_key_entry(entry);
>

Using sping_lock_irqsave() and spin_lock_irqrestore() in ima_queue_key()
is the right approach. Found a relevant blog below:

https://stackoverflow.com/questions/50637489/spin-lock-irqsave-in-interrupt-context

I think it would be safe to use the same spinlock functions in
ima_process_queued_keys() as well, but not a must.

Could you please confirm if your change fixed the crash?
I'll post a patch shortly.

thanks,
-lakshmi

\
 
 \ /
  Last update: 2020-01-14 18:19    [W:0.033 / U:22.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site