Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1937483imm; Thu, 24 May 2018 03:14:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp2isISxdV1E9IXMaz0uX/kHbYqVB5Ezx4o88ZY9vAcVzBpKZQEdXR6j8MQVR57YdUXp4Fm X-Received: by 2002:a63:5fc4:: with SMTP id t187-v6mr1805566pgb.183.1527156867910; Thu, 24 May 2018 03:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527156867; cv=none; d=google.com; s=arc-20160816; b=zNZ/uJ+A820mHUjTsWNQ3ielobUEwmPrUeOmclJREHkgzXp0cP/Hf1R4n81alI454z doDNRAkRaC+WiEUm922Cgj7XPu/fOrydC9K1Qh2UorVlx1KcxeXbQ04hmhtvx693W6yr TjrHq+V9y6KLjHz9lZXtUKKwwz/DLq+v404KY+Y2OhcnOwB6fNIu6IFG84ljOgpGsDHt pzcGm55JQUryA6o6cn6CBQYPFJj17Q3C8MfsQJhJWUUfjx9HEPtlm1MflpEii5DElpv7 q3VMntTrWYOuyD7HnnC8Dd/xw4PrSsdpB6dLXw62UjqByciq30rvt7wj1Fp8Ym28/6bv 09jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=CBWB/rqVhWjTJMIkFc/6SFsi8RZhNmupujmCiLqbkv8=; b=H8Rm/KNddvN0YbHZZbEiSLlGJld3TPeh3kTUzl4KYj/6KQBgTHkIrxgWTxpO0cV4pZ //ZWf6Muz+MI6swWxCo57MgdSasXrRzinSrab5r7zgcBjy2WR09SMtUaC/X2WP33l3Fu Ib383jZ1ZV0dTpqgn9aPIGQzk3tHd6bLZ3BSJwYOYlOzTHJpxD0vHnfDqx2EJK2jgo5F ipbdQUtJuMmJ6rbnh4g1Djeb7bUNTR9XVXkXktl+cZn5MU3Hsn3CgzIbvpp20FRu/lal WpSLwlKvNyLNWvSmDUd3gacYuX9gGwNRCzQ6A/T67uyGUozZxA8jXWP0X9oX6QgBAQpl 0aHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E0T7Ja1f; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8-v6si10876773plk.221.2018.05.24.03.14.13; Thu, 24 May 2018 03:14:27 -0700 (PDT) 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=@kernel.org header.s=default header.b=E0T7Ja1f; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031676AbeEXKNT (ORCPT + 99 others); Thu, 24 May 2018 06:13:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:54212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031142AbeEXKE5 (ORCPT ); Thu, 24 May 2018 06:04:57 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 73B8320891; Thu, 24 May 2018 10:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156297; bh=XRWyH+ajSc11THuw/FE6gqnYzwtCIwdfcoizxVUnZtk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E0T7Ja1fZS8iqN42ZMgzEQFqMvdjad3SMeNjTrIAv38gkVNovjC5BspCcnxTQyful WqmwgnHpTTIwPgXhAz1qMzSKfpcNP23UxRkVrL8g8S7iuPjLHI7RMVOpL0naSnzosc LTpxPXMwZUGwLsuOUKUK/TfJ+E60/w6vrFHiIBc8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gary R Hook , Sebastian Andrzej Siewior , Herbert Xu , Sasha Levin Subject: [PATCH 4.16 100/161] crypto: ccp - dont disable interrupts while setting up debugfs Date: Thu, 24 May 2018 11:38:45 +0200 Message-Id: <20180524093030.391952472@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sebastian Andrzej Siewior [ Upstream commit 79eb382b5e06a6dca5806465d7195d686a463ab0 ] I don't why we need take a single write lock and disable interrupts while setting up debugfs. This is what what happens when we try anyway: |ccp 0000:03:00.2: enabling device (0000 -> 0002) |BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:69 |in_atomic(): 1, irqs_disabled(): 1, pid: 3, name: kworker/0:0 |irq event stamp: 17150 |hardirqs last enabled at (17149): [<0000000097a18c49>] restore_regs_and_return_to_kernel+0x0/0x23 |hardirqs last disabled at (17150): [<000000000773b3a9>] _raw_write_lock_irqsave+0x1b/0x50 |softirqs last enabled at (17148): [<0000000064d56155>] __do_softirq+0x3b8/0x4c1 |softirqs last disabled at (17125): [<0000000092633c18>] irq_exit+0xb1/0xc0 |CPU: 0 PID: 3 Comm: kworker/0:0 Not tainted 4.16.0-rc2+ #30 |Workqueue: events work_for_cpu_fn |Call Trace: | dump_stack+0x7d/0xb6 | ___might_sleep+0x1eb/0x250 | down_write+0x17/0x60 | start_creating+0x4c/0xe0 | debugfs_create_dir+0x9/0x100 | ccp5_debugfs_setup+0x191/0x1b0 | ccp5_init+0x8a7/0x8c0 | ccp_dev_init+0xb8/0xe0 | sp_init+0x6c/0x90 | sp_pci_probe+0x26e/0x590 | local_pci_probe+0x3f/0x90 | work_for_cpu_fn+0x11/0x20 | process_one_work+0x1ff/0x650 | worker_thread+0x1d4/0x3a0 | kthread+0xfe/0x130 | ret_from_fork+0x27/0x50 If any locking is required, a simple mutex will do it. Cc: Gary R Hook Signed-off-by: Sebastian Andrzej Siewior Acked-by: Gary R Hook Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/ccp/ccp-debugfs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/drivers/crypto/ccp/ccp-debugfs.c +++ b/drivers/crypto/ccp/ccp-debugfs.c @@ -278,7 +278,7 @@ static const struct file_operations ccp_ }; static struct dentry *ccp_debugfs_dir; -static DEFINE_RWLOCK(ccp_debugfs_lock); +static DEFINE_MUTEX(ccp_debugfs_lock); #define MAX_NAME_LEN 20 @@ -290,16 +290,15 @@ void ccp5_debugfs_setup(struct ccp_devic struct dentry *debugfs_stats; struct dentry *debugfs_q_instance; struct dentry *debugfs_q_stats; - unsigned long flags; int i; if (!debugfs_initialized()) return; - write_lock_irqsave(&ccp_debugfs_lock, flags); + mutex_lock(&ccp_debugfs_lock); if (!ccp_debugfs_dir) ccp_debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL); - write_unlock_irqrestore(&ccp_debugfs_lock, flags); + mutex_unlock(&ccp_debugfs_lock); if (!ccp_debugfs_dir) return;