From patchwork Sat Nov 19 18:32:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 9438331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 56EE960469 for ; Sat, 19 Nov 2016 18:33:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C0AC28741 for ; Sat, 19 Nov 2016 18:33:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F7FB28F4C; Sat, 19 Nov 2016 18:33:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DBFEB28741 for ; Sat, 19 Nov 2016 18:33:05 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1c8ARj-0003hF-IY; Sat, 19 Nov 2016 18:33:03 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1c8ARi-0003hA-Vz for tpmdd-devel@lists.sourceforge.net; Sat, 19 Nov 2016 18:33:03 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of obsidianresearch.com designates 184.70.90.242 as permitted sender) client-ip=184.70.90.242; envelope-from=jgunthorpe@obsidianresearch.com; helo=quartz.orcorp.ca; Received: from quartz.orcorp.ca ([184.70.90.242]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1c8ARi-0007lu-1y for tpmdd-devel@lists.sourceforge.net; Sat, 19 Nov 2016 18:33:02 +0000 Received: from jgg by quartz.orcorp.ca with local (Exim 4.84_2) (envelope-from ) id 1c8ARb-0006cg-R9; Sat, 19 Nov 2016 11:32:55 -0700 Date: Sat, 19 Nov 2016 11:32:55 -0700 From: Jason Gunthorpe To: Stefan Berger Message-ID: <20161119183255.GB22775@obsidianresearch.com> References: <1479306245-14456-1-git-send-email-stefanb@linux.vnet.ibm.com> <20161116153731.pmmnxiai7ouuj6qf@intel.com> <3a38ddc6-1758-ae82-3df3-9cc55906880d@linux.vnet.ibm.com> <65f392b6-5141-c726-dacb-a1649ea215de@linux.vnet.ibm.com> <20161116200759.GA19593@obsidianresearch.com> <20161117181006.GA26039@obsidianresearch.com> <20161117183328.GC26039@obsidianresearch.com> <513da75c-6221-39ce-2718-19290c216ff1@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <513da75c-6221-39ce-2718-19290c216ff1@linux.vnet.ibm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Headers-End: 1c8ARi-0007lu-1y Cc: tpmdd-devel@lists.sourceforge.net Subject: Re: [tpmdd-devel] [PATCH] tpm: vtpm_proxy: Do not access host's event log X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Nov 17, 2016 at 06:15:20PM -0500, Stefan Berger wrote: > >>Further, I had the impression that the error unwinding following -ENODEV has > >>an issue related to sysfs. > >I don't follow this comment.. > > I have encountered this error here, which gets masked when applying the > previously shown patch. If tpm_chip_register fails vtpm must not call tpm_chip_unregister: > [ 58.271017] [] dpm_sysfs_remove+0x22/0x60 > [ 58.271017] [] device_del+0x58/0x280 > [ 58.271017] [] tpm_chip_unregister+0x40/0xb0 [tpm] > [ 58.271017] [] vtpm_proxy_fops_release+0x40/0x60 [tpm_vtpm_proxy] So, this is a vtpm thing I missed for 'tpm: Get rid of TPM_CHIP_FLAG_REGISTERED' Does this do the trick? ------------------------------------------------------------------------------ Tested-by: Stefan Berger Tested-by: Jarkko Sakkinen Reviewed-by: Jarkko Sakkinen diff --git a/drivers/char/tpm/tpm_vtpm_proxy.c b/drivers/char/tpm/tpm_vtpm_proxy.c index 3d6f6ca81def75..d3a41f9d65c85c 100644 --- a/drivers/char/tpm/tpm_vtpm_proxy.c +++ b/drivers/char/tpm/tpm_vtpm_proxy.c @@ -42,6 +42,7 @@ struct proxy_dev { long state; /* internal state */ #define STATE_OPENED_FLAG BIT(0) #define STATE_WAIT_RESPONSE_FLAG BIT(1) /* waiting for emulator response */ +#define STATE_REGISTERED_FLAG BIT(2) size_t req_len; /* length of queued TPM request */ size_t resp_len; /* length of queued TPM response */ @@ -372,6 +373,7 @@ static void vtpm_proxy_work(struct work_struct *work) if (rc) goto err; + proxy_dev->state |= STATE_REGISTERED_FLAG; return; err: @@ -516,7 +518,8 @@ static void vtpm_proxy_delete_device(struct proxy_dev *proxy_dev) */ vtpm_proxy_fops_undo_open(proxy_dev); - tpm_chip_unregister(proxy_dev->chip); + if (proxy_dev->state & STATE_REGISTERED_FLAG) + tpm_chip_unregister(proxy_dev->chip); vtpm_proxy_delete_proxy_dev(proxy_dev); }