From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 513B8C33C9E for ; Tue, 14 Jan 2020 16:54:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 21167214AF for ; Tue, 14 Jan 2020 16:54:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="PhSTT93H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728708AbgANQyQ (ORCPT ); Tue, 14 Jan 2020 11:54:16 -0500 Received: from linux.microsoft.com ([13.77.154.182]:44706 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728688AbgANQyQ (ORCPT ); Tue, 14 Jan 2020 11:54:16 -0500 Received: from [10.137.112.111] (unknown [131.107.147.111]) by linux.microsoft.com (Postfix) with ESMTPSA id 3BAC320B4798; Tue, 14 Jan 2020 08:54:15 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3BAC320B4798 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1579020855; bh=Ucmyx/fCw1Ra6TuNnQWAln3iWLXAArkz0UXjKyjbhHU=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=PhSTT93HCojtCk5FZzm1Yc7XHAOgihAHujoeZCsaYCx1X16CwKuWE15Bo0fUYfo8j VnaN0NIcMkJFAXXtMVzGndOX8BDm3aftJvmT05IJbrjT83QmV8dJUwzAk45yi1OQwS imGeSlNiQFKg8kwZJmre3K4C/rXaYjZLiRHth2bo= Subject: Re: inconsistent lock state in ima_process_queued_keys To: Dmitry Vyukov , Mimi Zohar Cc: syzbot , Dmitry Kasatkin , James Morris , linux-integrity@vger.kernel.org, LKML , linux-security-module , "Serge E. Hallyn" , syzkaller-bugs References: <000000000000486474059c19f4d7@google.com> <1579013812.12230.21.camel@linux.ibm.com> From: Lakshmi Ramasubramanian Message-ID: Date: Tue, 14 Jan 2020 08:54:32 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: I am investigating this. thanks, -lakshmi On 1/14/2020 7:21 AM, Dmitry Vyukov wrote: > On Tue, Jan 14, 2020 at 3:57 PM Mimi Zohar wrote: >> >> On Tue, 2020-01-14 at 14:58 +0100, Dmitry Vyukov wrote: >>> On Tue, Jan 14, 2020 at 2:56 PM syzbot >>> 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@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); >