From patchwork Thu Apr 27 18:26:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Zimmerman X-Patchwork-Id: 9703359 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 47287601D3 for ; Thu, 27 Apr 2017 18:27:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4205B280CF for ; Thu, 27 Apr 2017 18:27:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35EA82865D; Thu, 27 Apr 2017 18:27:41 +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, DKIM_ADSP_CUSTOM_MED, 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 985B6280CF for ; Thu, 27 Apr 2017 18:27:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1d3o8g-0006QA-Km; Thu, 27 Apr 2017 18:27:38 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1d3o8f-0006Q4-R9 for tpmdd-devel@lists.sourceforge.net; Thu, 27 Apr 2017 18:27:37 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of google.com designates 209.85.192.182 as permitted sender) client-ip=209.85.192.182; envelope-from=joshz@google.com; helo=mail-pf0-f182.google.com; Received: from mail-pf0-f182.google.com ([209.85.192.182]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1d3o8e-0007gE-Tz for tpmdd-devel@lists.sourceforge.net; Thu, 27 Apr 2017 18:27:37 +0000 Received: by mail-pf0-f182.google.com with SMTP id a188so34517047pfa.0 for ; Thu, 27 Apr 2017 11:27:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=DZklOt6VKtsAb/oSgi1u9CHFP4FgiGysWmpqW0dDYus=; b=Ru6m1cJkAmpb/SkvAYaof6wT1H47wDuxpuajxaVMUDjmXFiHPf5Jq5u8TtLNOzOO7y bQrn8aisaL21Yot1UX5VAkjWrk32BvMOqfHMGfxqW2XBrGnZwId+gLpRe/ELyPBVcCyF mlznlGN7NoGMPtJiGDkiUyFFBFKEPxa5u39qz99mN2IwnJ4+DqpJMS3KZXffxHe1JaSt 8rQprH8F1GArCiFdiNUzMUePNWrA5pJGcZ4Dh4wc0BEPtasUjj0G1GChd9SBoJWk1pBu lPfLkrV6boV74O2XFxQYcV4Ma3DQh1yYte4GImZSDYACXYD19qxHMjgPQ992jCr1jGN8 Yfkg== X-Gm-Message-State: AN3rC/4cecEqP7nbnRgc8qKa/v4DKvdnSZJj5sYOmn8Zsr0AALDGXKz7 +P0TAPMciC+knA8y X-Received: by 10.98.80.156 with SMTP id g28mr7382948pfj.163.1493317651097; Thu, 27 Apr 2017 11:27:31 -0700 (PDT) Received: from angband.kir.corp.google.com ([100.119.30.20]) by smtp.googlemail.com with ESMTPSA id v187sm5434977pgv.18.2017.04.27.11.27.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Apr 2017 11:27:30 -0700 (PDT) From: Josh Zimmerman To: Peter Huewe , Marcel Selhorst , Jarkko Sakkinen , Jason Gunthorpe , tpmdd-devel@lists.sourceforge.net Date: Thu, 27 Apr 2017 11:26:59 -0700 Message-Id: <20170427182659.403-1-joshz@google.com> X-Mailer: git-send-email 2.13.0.rc0.306.g87b477812d-goog X-Headers-End: 1d3o8e-0007gE-Tz Subject: [tpmdd-devel] [PATCH] tpm_tis: Issue a TPM2_Shutdown for TPM2 devices. 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: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Virus-Scanned: ClamAV using ClamSMTP If a TPM2 loses power without a TPM2_Shutdown command being issued, it may lose some state that has yet to be persisted to NVRam, and will increment the DA counter (meaning that after too many disorderly reboots, the TPM will lock the user out). This is a variant of https://patchwork.kernel.org/patch/9516631/. It differs in that: * It only changes behavior on TPM2 devices, to avoid invoking the unbounded-waiting sysfs codepath that was discussed on that patch. * It modifies tpm_tis rather than tpm_i2c_infineon, so that it can change behavior for all TPM2 devices. Signed-off-by: Josh Zimmerman --- drivers/char/tpm/tpm_tis.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index c7e1384f1b08..bd9c70b305ab 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c @@ -216,11 +216,23 @@ static void tpm_tis_pnp_remove(struct pnp_dev *dev) tpm_tis_remove(chip); } +static void tpm_tis_pnp_shutdown(struct pnp_dev *dev) +{ + struct tpm_chip *chip = pnp_get_drvdata(dev); + // TPM 2.0 requires that the TPM2_Shutdown() command be issued prior to loss of power. + // If it is not, the DA counter will be incremented and, eventually, the user will be + // locked out of their TPM. + if (chip->flags & TPM_CHIP_FLAG_TPM2) { + tpm_tis_pnp_remove(dev); + } +} + static struct pnp_driver tis_pnp_driver = { .name = "tpm_tis", .id_table = tpm_pnp_tbl, .probe = tpm_tis_pnp_init, .remove = tpm_tis_pnp_remove, + .shutdown = tpm_tis_pnp_shutdown, .driver = { .pm = &tpm_tis_pm, },