Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4594976ybl; Mon, 9 Dec 2019 13:35:12 -0800 (PST) X-Google-Smtp-Source: APXvYqwypCybh8DZAr8mcG0Cm7aSFiVNROxLM8y6y4UkbSjfdHHbeONUtEEajXtqQmWOcRuNEsxW X-Received: by 2002:a54:4485:: with SMTP id v5mr1092194oiv.144.1575927312194; Mon, 09 Dec 2019 13:35:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575927312; cv=none; d=google.com; s=arc-20160816; b=G4gBf3G7uQpZzX6dewD4M1cFFpfO+Vtyk3fNq7IlJrw6JWSQsh3iP8ICgX+qHTsOD6 ubAQDUBe9Lbg7L7S8bJzv1QjvIq49nVk2CP9gnfAvnmG59IBD8znlbl4nBvwfHbleaHI U78sn7/WCj6ibJXg4NmEDlqhoRh0m3GI+SvqdeLVgiYO2/ka4iWMJaZMp0tDNOX1BCw4 2vPpSx0nQTXyZTrzqe1zud4MHct7dJJluB+my8Bg/xnDSC2y6kMSZ15AUJiQqrf+ng+p 3QV2GJ5KSEL8xQhpEvbhFJBlF0g+ADpK9KVJCajqcIaCV/PuVyyAmVOba0N0mhFjXc8W TK4w== 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:autocrypt:from:references:cc:to:subject; bh=TV6d7E8YVNPKj5lQNqqhib/zzjl3VCwTaK8U8dt5CTA=; b=OIkcVc08wYJFW4IjQUypCBSeolu+ksnSIqW/be4f9QBUG86wAD7IjvfO7TgYQyjyhK LweVdK03nMFCSEYADp1B+0eqer5oc2VMArH3rbMQJzvZKQO3+eGdMKrmnGbKnZN6YHU5 V9BISCeMOEGSjUiohfoDgWZPxY6yYT1pmaeaZmK28l1DcfByewDUD5q4NEkhGu+Ws5wy 0EI5Ew64lelAtEMIRfA0nZubwxjhn6ADU8mbxat+KCLiFWqhEbOBAsqpgGpm31gfqqkm 4m8hWniBg9/M4D0EH3gju/TEPf1MoFwjNIThHyQXNoJviUbgf5ozdePJL/iauWFPQVSQ PmiA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3si686906otk.60.2019.12.09.13.34.58; Mon, 09 Dec 2019 13:35:12 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726614AbfLIVea (ORCPT + 99 others); Mon, 9 Dec 2019 16:34:30 -0500 Received: from mga01.intel.com ([192.55.52.88]:18340 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726408AbfLIVea (ORCPT ); Mon, 9 Dec 2019 16:34:30 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Dec 2019 13:34:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,296,1571727600"; d="scan'208";a="224929832" Received: from tstruk-mobl1.jf.intel.com (HELO [10.7.196.67]) ([10.7.196.67]) by orsmga002.jf.intel.com with ESMTP; 09 Dec 2019 13:34:29 -0800 Subject: Re: [PROBLEM]: WARNING: lock held when returning to user space! (5.4.1 #16 Tainted: G ) To: Jarkko Sakkinen , Will Deacon Cc: Jeffrin Jose , peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, peterhuewe@gmx.de, jgg@ziepe.ca References: <20191207173420.GA5280@debian> <20191209103432.GC3306@willie-the-truck> <20191209202552.GK19243@linux.intel.com> From: Tadeusz Struk Autocrypt: addr=tadeusz.struk@intel.com; keydata= mQGNBF2okUMBDADGYZuwqK87k717uEyQ5hqo9X9ICnzpPt38ekB634MdtBwdK8KAFRWIpnT9 fb5bt/AFgGc1gke/Nr8PFsFcRiNTDuWpwO/zJdWWp+fdnB9dKI0usYY9+Y5Q3lhBeiBN7mDK fAoFjyeufKzY3pOM9Gy6FvGQjDyLm2H5siW0IKAsMjAiQ35qI7hednM2XECHqewt4yzxvPZr LpgpFvR43nJBUGULGPWqv0usVircd1bBJ4D24j/kaYmuDeyex/HdqTV8sWBx3NFFKtyZB7FV EPekbHIxaRxg3kgZzCKXrwoufLR5ErGO/oqJmGjuCMWp14iZ0mtN4BzYdhzqHmtJhc8/nSwV NIZUF+JpMk/KpYcPlpmMzBcLKHkAhEvIEoynKCcFHqNUjeu+tqL4Nc6Wl36T2EQw3u9hDk4Y uX4ZGe6BzADl8Sphgyld99I4jAeoEzSCbWnqS411iVPXyxfe+46zuW3ORncxNoyy3EqGu8m5 347fgFADQpc9+jdc1qFcxncAEQEAAbQnVGFkZXVzeiBTdHJ1ayA8dGFkZXVzei5zdHJ1a0Bp bnRlbC5jb20+iQHUBBMBCAA+FiEE91vcGmaCEzGCRUztOkAW4c1UqhwFAl2okUcCGwMFCQHh M4AFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQOkAW4c1UqhwVZQv/dTaTLe1s6xFyAkYJ aK8IqKOYo2s29bTDoeul7U2WFivgryGRX3mNblMfV6lwwRcNfjSF+gOVrT6+N1l2vrDmqtPG ywKjrL18C7TssAxj7oIDSdRCHbIRjHs6N2jm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IeGI+4c2EDfFRigzY4GiseN8HNhl5t2jEb5FX/M6WHVCfNt vGz6dVAaES6z4UqWW8cP1insosSFi5slHjoUNk9Sx9FQ/oIX9FemLxxH4HcFlxGmUrVUiiof en/LmOP4UBVPxRJ20UeFOD3XcwQerS0r4LEK2Zpl/lB7WbGSCZjoVq9xhv5i+9Z04KvVkTCY T/vfPu+7KPf+gxGMZZqi+mILWBzCbhOa25HOjeJ780zGDQa05DF6WWepIlNYoiaYeqwhcmWP gwizcH5TjTP7SF96/2USKmZCsgKKiVy4a9yHyafeDxCa6NwL1wVRaCqJhdtjgfGrcSx0u++F H5Vo0zSBk5Nx0fx2HT16roAnfoOj4wLa/0xVtt+9XXdcoueQwO4imuUeR1Spm1Yni1oBuaR3 yvcQkH/25MiQZ3/8hU+0Tpfy9SPQyBxrtguvPBPfRg== Message-ID: <34e5340f-de75-f20e-7898-6142eac45c13@intel.com> Date: Mon, 9 Dec 2019 13:34:29 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 MIME-Version: 1.0 In-Reply-To: <20191209202552.GK19243@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/9/19 12:25 PM, Jarkko Sakkinen wrote: > On Mon, Dec 09, 2019 at 10:34:32AM +0000, Will Deacon wrote: >> Hi, >> >> [expanding cc list] >> >> On Sat, Dec 07, 2019 at 11:04:20PM +0530, Jeffrin Jose wrote: >>> i got the following output related from typical dmesg output from 5.4.1 kernel >> >> Was this during boot or during some other operation? >> >>> ================================================ >>> WARNING: lock held when returning to user space! >>> 5.4.1 #16 Tainted: G E >>> ------------------------------------------------ >>> tpm2-abrmd/691 is leaving the kernel with locks still held! >>> 2 locks held by tpm2-abrmd/691: >>> #0: ffff8881ee784ba8 (&chip->ops_sem){.+.+}, at: tpm_try_get_ops+0x2b/0xc0 [tpm] >>> #1: ffff8881ee784d88 (&chip->tpm_mutex){+.+.}, at: tpm_try_get_ops+0x57/0xc0 [tpm] >> >> Can you reproduce this failure on v5.5-rc1? > > Does this appear after variable amount of time or detemitically always > at certain point of time (e.g. when the daemon starts or perhaps always > when doing a certain operations with TSS)? > > Do we have possibility to get the user code path that gets executed when > this happens? I think that's expected for a non-blocking operation. To get rid of the warning it should be changed to something like this: diff --git a/drivers/char/tpm/tpm-dev-common.c b/drivers/char/tpm/tpm-dev-common.c index 2ec47a69a2a6..47f1c0c5c8de 100644 --- a/drivers/char/tpm/tpm-dev-common.c +++ b/drivers/char/tpm/tpm-dev-common.c @@ -61,6 +61,12 @@ static void tpm_dev_async_work(struct work_struct *work) mutex_lock(&priv->buffer_mutex); priv->command_enqueued = false; + ret = tpm_try_get_ops(priv->chip); + if (ret) { + priv->response_length = ret; + goto out; + } + ret = tpm_dev_transmit(priv->chip, priv->space, priv->data_buffer, sizeof(priv->data_buffer)); tpm_put_ops(priv->chip); @@ -68,6 +74,7 @@ static void tpm_dev_async_work(struct work_struct *work) priv->response_length = ret; mod_timer(&priv->user_read_timer, jiffies + (120 * HZ)); } +out: mutex_unlock(&priv->buffer_mutex); wake_up_interruptible(&priv->async_wait); } @@ -205,6 +212,7 @@ ssize_t tpm_common_write(struct file *file, const char __user *buf, priv->command_enqueued = true; queue_work(tpm_dev_wq, &priv->async_work); mutex_unlock(&priv->buffer_mutex); + tpm_put_ops(priv->chip); return size; } -- Tadeusz