Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp14469126ybl; Mon, 30 Dec 2019 10:38:53 -0800 (PST) X-Google-Smtp-Source: APXvYqxwTZJPfyk3L3JFxSO4YCoYX6SpS3hrbbElrDX5eTtsNaZK51ac49h75YlyB2NMtI2bdQpF X-Received: by 2002:a05:6830:1f89:: with SMTP id v9mr71930907otr.90.1577731133872; Mon, 30 Dec 2019 10:38:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577731133; cv=none; d=google.com; s=arc-20160816; b=Xo/q8fnj8AkCkZ+P57xBIvdn6WonglLRDC+di8lySLSULGDitMMsKj9ZuuO8h2O3mT tL4TIn9YIWD4W4qAcB9vAkgN7uxP8S+RPIiqdercSJT21QL5ZC1rAGaoJGykkiM2vu0C XEKIlv1DLYHz62958Q5zgkxq/nGCquQKo3Xcz0YaX8lmAJpXtU2EthugJDo/EY0fa8mS CNdF0ssq/UlynPiqh4hyzKS4QRPk2IWBhi2swilveK+OrA5iYnJ2IXlhqra74d4JNg7g xddInF8HklA29IKCI87sBCQieJHkk5nJW5UP5yJ/V+SfGrqsRMzo98cM3+m1R+Hbmb5c SwJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature:dkim-filter; bh=poXSaoy0MgWUlq8+h6lljwkSbM6p9BtBLLhoUaT8cK8=; b=BTBAu3ryWlTm5UEEUwcl6Go8kaAi65oOguFuLZJ1yuo9SjvSsWOEdJZoh8Z9x2lNmg crBBN27io/S4SyrWQH5cTkpQ7si7u1GyFgOYMlZUPrZ69pzNaXxy9/GJrX9Q9rhsWEki imsKbGxZBDMWicqTT2NydQEKC9v9YaFUjsZX2b8kuiXPBiWaNADXF3GfdprPlQ+aBOQW LxWlDOkhnCDm5WrH1vww9znL3lm0BqOeiI08BL6GF84bKFobwqcZywTZh662zgQrWFN/ vilPiSPA5wbE/QD1a+SHE3SHAQM3nwP3TNX3zwo7+7L2HJqs1RWXblzirRQZaXwI70bY cSKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=HOpxi7Be; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v145si21101487oia.68.2019.12.30.10.38.42; Mon, 30 Dec 2019 10:38:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=HOpxi7Be; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727619AbfL3Shf (ORCPT + 99 others); Mon, 30 Dec 2019 13:37:35 -0500 Received: from linux.microsoft.com ([13.77.154.182]:33424 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727511AbfL3Shf (ORCPT ); Mon, 30 Dec 2019 13:37:35 -0500 Received: from [10.137.112.108] (unknown [131.107.174.108]) by linux.microsoft.com (Postfix) with ESMTPSA id 1BB6720B4798; Mon, 30 Dec 2019 10:37:34 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1BB6720B4798 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1577731054; bh=poXSaoy0MgWUlq8+h6lljwkSbM6p9BtBLLhoUaT8cK8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=HOpxi7BeXrHZKEbX7P3vH8BAwscdv6zPC/2l5Ai+S5GSlTRHguLwZPPB3j6tg05Av fJEYdEzaV/iUDwjs3WSQZrTHb2gOcJ8i2wwYiFp7e4mo5fCoN2uMOX2cjYrcmfAKi8 6jriM0oYxedpcSnZMUJSS8RsXEqu+7/R4tYtkprw= Subject: Re: [IMA] 11b771ffff: BUG:sleeping_function_called_from_invalid_context_at_kernel/locking/mutex.c To: Mimi Zohar , kernel test robot Cc: LKML , Mimi Zohar , linux-integrity@vger.kernel.org, lkp@lists.01.org References: <20191227142335.GE2760@shao2-debian> <1577725301.5874.32.camel@linux.ibm.com> From: Lakshmi Ramasubramanian Message-ID: Date: Mon, 30 Dec 2019 10:37:30 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <1577725301.5874.32.camel@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/30/19 9:01 AM, Mimi Zohar wrote: Hi Mimi, > Hi Lakshmi, > > On Fri, 2019-12-27 at 22:23 +0800, kernel test robot wrote: >> [ 333.455345] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:281 >> [ 333.457243] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 12395, name: userfaultfd >> [ 333.458888] CPU: 1 PID: 12395 Comm: userfaultfd Not tainted 5.5.0-rc1-00011-g11b771ffff8fc #1 >> [ 333.461096] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014 >> [ 333.463893] Call Trace: >> [ 333.465287] >> [ 333.466351] dump_stack+0x66/0x8b >> [ 333.467346] ___might_sleep+0x102/0x120 >> [ 333.468385] mutex_lock+0x1c/0x40 >> [ 333.469421] ima_process_queued_keys+0x24/0x110 >> [ 333.470529] ? ima_process_queued_keys+0x110/0x110 >> [ 333.471656] call_timer_fn+0x2d/0x140 >> [ 333.472707] run_timer_softirq+0x46f/0x4b0 >> [ 333.473752] ? enqueue_hrtimer+0x39/0xa0 >> [ 333.474780] __do_softirq+0xe3/0x2f8 >> [ 333.475768] irq_exit+0xd5/0xe0 >> [ 333.476738] smp_apic_timer_interrupt+0x74/0x140 >> [ 333.477834] apic_timer_interrupt+0xf/0x20 >> [ 333.478858] > > I think this is an instance where defining timer_expired as atomic and > then testing it using atomic_dec_and_test() would help.  Either the > queued keys would be deleted in ima_timer_handler() or measured in > ima_process_queued_keys(). > > Mimi Would it be better to use a spinlock (instead of a mutex) to synchronize access to the queued keys list? That would work for timer callback function also. Before submitting the patch for freeing the keys I had tested the case where queued keys are freed in timer callback. But I did not hit the above break. I will follow the steps given by Rong and validate the fix. thanks, -lakshmi