inconsistent lock state in ima_process_queued_keys
Dmitry Vyukov
dvyukov at google.com
Tue Jan 14 15:21:07 UTC 2020
On Tue, Jan 14, 2020 at 3:57 PM Mimi Zohar <zohar at linux.ibm.com> wrote:
>
> On Tue, 2020-01-14 at 14:58 +0100, Dmitry Vyukov wrote:
> > On Tue, Jan 14, 2020 at 2:56 PM syzbot
> > <syzbot+a4a503d7f37292ae1664 at syzkaller.appspotmail.com> wrote:
> > >
> > > Hello,
> > >
> > > syzbot found the following crash on:
> > >
> > > HEAD commit: 1b851f98 Add linux-next specific files for 20200114
> > > git tree: linux-next
> > > console output: https://syzkaller.appspot.com/x/log.txt?x=12bcbb25e00000
> > > kernel config: https://syzkaller.appspot.com/x/.config?x=3e7d9cf7ebfa08ad
> > > dashboard link: https://syzkaller.appspot.com/bug?extid=a4a503d7f37292ae1664
> > > compiler: gcc (GCC) 9.0.0 20181231 (experimental)
> > >
> > > Unfortunately, I don't have any reproducer for this crash yet.
> > >
> > > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > > Reported-by: syzbot+a4a503d7f37292ae1664 at syzkaller.appspotmail.com
> >
> > +Lakshmi, you seem to have submitted a number of changes to this file recently.
> >
> > This completely breaks linux-next testing for us, every kernel crashes
> > a few minutes after boot.
> >
> > 2020/01/14 14:45:00 vm-26: crash: inconsistent lock state in
> > ima_process_queued_keys
>
> Yikes! Are you running with an IMA policy?
I don't know.
> I assume this is being
> caused by commit 8f5d2d06f217 ("IMA: Defined timer to free queued
> keys". Does reverting it prevent this from happening?
The following seems to help, but don't know if it's the right fix or not.
diff --git a/security/integrity/ima/ima_asymmetric_keys.c
b/security/integrity/ima/ima_asymmetric_keys.c
index 61e478f9e8199..49d559501fe62 100644
--- 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);
More information about the Linux-security-module-archive
mailing list