public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>
To: Dmitry Vyukov <dvyukov@google.com>, Mimi Zohar <zohar@linux.ibm.com>
Cc: syzbot <syzbot+a4a503d7f37292ae1664@syzkaller.appspotmail.com>,
	Dmitry Kasatkin <dmitry.kasatkin@gmail.com>,
	James Morris <jmorris@namei.org>,
	linux-integrity@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	linux-security-module <linux-security-module@vger.kernel.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	syzkaller-bugs <syzkaller-bugs@googlegroups.com>
Subject: Re: inconsistent lock state in ima_process_queued_keys
Date: Tue, 14 Jan 2020 09:19:06 -0800	[thread overview]
Message-ID: <52f0bced-2d8b-bdf4-b65a-26689ea1aed1@linux.microsoft.com> (raw)
In-Reply-To: <CACT4Y+bgQVmibpeJgpwb_JTKW6jx3dzv0M-NGVat8qvJTo4X7A@mail.gmail.com>

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


  parent reply	other threads:[~2020-01-14 17:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-14 13:56 inconsistent lock state in ima_process_queued_keys syzbot
2020-01-14 13:58 ` Dmitry Vyukov
2020-01-14 14:56   ` Mimi Zohar
2020-01-14 15:21     ` Dmitry Vyukov
2020-01-14 16:54       ` Lakshmi Ramasubramanian
2020-01-14 17:19       ` Lakshmi Ramasubramanian [this message]
2020-01-18  3:14 ` syzbot
2020-01-18  5:22   ` Lakshmi Ramasubramanian

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=52f0bced-2d8b-bdf4-b65a-26689ea1aed1@linux.microsoft.com \
    --to=nramas@linux.microsoft.com \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=dvyukov@google.com \
    --cc=jmorris@namei.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=serge@hallyn.com \
    --cc=syzbot+a4a503d7f37292ae1664@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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