From patchwork Fri Nov 16 12:38:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 10686179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 860F217DE for ; Fri, 16 Nov 2018 12:40:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73CD32CD53 for ; Fri, 16 Nov 2018 12:40:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67F222CD56; Fri, 16 Nov 2018 12:40:24 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1585B2CD53 for ; Fri, 16 Nov 2018 12:40:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=zECSux40EF9XZ2Pj0Tv6cInpPC5jTM3FtJKWTPekToc=; b=KrJnGYJl4dBXOn 6CFMxUIU3+J4qPyXAdbLM1+mO5O9vB2GkH7lefYCYIvBtUxaBmP2GKUjTUlU87cok8d0gHivble3Z nleGhAzPPGUj44iJIhJdTP0Mz/1bZPDOd6HGb46atyiinfiI9PEmrnv+RQBK5syGwqxyQa+cWjkE3 fEhcygQNk4GQuiWAtLjLTwOAE58suivp1Hy+82TM99D7WbgbMsY21xvoiACWZg4ZiQJyHsf2KGNDg thoiRZgZudnr63QTM3wS0qCSoE/cJ6FC4GaYO80B8kIuFN4P7GIaBRVBRpCC7ijnUrzP8DHC4i536 Z/DHZamEuuBtgRSLTa0w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gNdQ6-0006lF-O5; Fri, 16 Nov 2018 12:40:22 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gNdQ5-0006kp-3s for linux-arm-kernel@bombadil.infradead.org; Fri, 16 Nov 2018 12:40:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=q8cn5TpvnDyTk7vS5LiDwkJyCT7J0yOnURaCQVzvtrw=; b=ulkJ9lDCigBRmA3T32UcYUWmhW f1r1JxKLDJaBX6yUgGq1lB6iVjhNDQQO3aLZfpDNg3CoyMK9BR1E6YgQ12oP7j62WXg8sTdEoCdcz z8mPjVQ2T4rP+bbmf2P8V2mcE7happBmAasi6suNhtSBGpJ+q/m1dEZi26XEkCr4Nr3A2CesdQML4 GkJ9mlFtPBNLxxVYjhzESoRSKQ5WxJkPDg0zTc3W46NpZ27BXt3NacGrgRP63TdhteA3lzXzcWSrI +UPwpoCMb93QFcAYlHoBopKEwU/6D5ztgO5/5RhPBPtWc1KvC5aNFSB0w8S884d3L5sMETeAiVN3y 0AWlKoWg==; Received: from mga06.intel.com ([134.134.136.31]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gNdQ2-0008LO-3g for linux-arm-kernel@lists.infradead.org; Fri, 16 Nov 2018 12:40:19 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Nov 2018 04:39:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,240,1539673200"; d="scan'208";a="96821100" Received: from unknown (HELO localhost) ([10.249.254.90]) by FMSMGA003.fm.intel.com with ESMTP; 16 Nov 2018 04:38:59 -0800 From: Jarkko Sakkinen To: linux-integrity@vger.kernel.org Subject: [PATCH v8 00/17] Removed nested TPM operations Date: Fri, 16 Nov 2018 14:38:24 +0200 Message-Id: <20181116123845.15705-1-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181116_074018_287469_D125BB38 X-CRM114-Status: GOOD ( 13.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Berger , Nayna Jain , open list , Tadeusz Struk , James Bottomley , Jason Gunthorpe , linux-security-module@vger.kernel.org, Jarkko Sakkinen , Tomas Winkler , "moderated list:ARM/Microchip AT91 SoC support" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP [was Detach TPM space code out of the tpm_transmit() flow but the scope expanded a bit.] Make the changes necessary to detach TPM space code and TPM activation code out of the tpm_transmit() flow because of both of these can cause nested tpm_transmit() calls. The nesteds calls make the whole flow hard to maintain, and thus, it is better to just fix things now before this turns into a bigger mess. v8: * Re-add the check for ret < 0 after calling tpm_try_transmit() that was dropped by mistake while moving code. * Fix error fallback for tpm_try_get_ops() when tpm_chip_start() fails. v7: * Reorganize series so that more trivial and self-contained changes are in the head. v6: * When tpm_validate_commmand() was moved to tpm2-space.c, the struct for the TPM header was incorrectly declared as struct tpm_input_header. * Fix return value in tpm_validate_command(). v5: * Add the missing rev's from Stefan Berger. v4: * Return 0 from pcrs_show() when tpm1_pcr_read() fails. * Fix error handling flow in tpm_try_transmit(). * Replace struct tpm_input_header and struct tpm_output_header with struct tpm_header. v3: * Encapsulate power gating code to tpm_chip_start() and tpm_chip_stop(). * Move TPM power gating code and locking to tpm_try_get_ops() and tpm_put_ops(). * Call power gating code directly in tpm_chip_register() and tpm2_del_space(). v2: * Print tpm2_commit_space() error inside tpm2_commit_space() * Error code was not printed when recv() callback failed. It is fixed in this version. * Added a patch that removes @space from tpm_transmit(). * Fixed a regression in earlier series. Forgot to amend the change from the staging area that renames NESTED to UNLOCKED in tpm2-space.c. Jarkko Sakkinen (17): tpm: use tpm_buf in tpm_transmit_cmd() as the IO parameter tpm: fix invalid return value in pubek_show() tpm: return 0 from pcrs_show() when tpm1_pcr_read() fails tpm: print tpm2_commit_space() error inside tpm2_commit_space() tpm: declare struct tpm_header tpm: access command header through struct in tpm_try_transmit() tpm: encapsulate tpm_dev_transmit() tpm: call tpm2_flush_space() on error in tpm_try_transmit() tpm: clean up tpm_try_transmit() error handling flow tpm: move tpm_validate_commmand() to tpm2-space.c tpm: move TPM space code out of tpm_transmit() tpm: remove @space from tpm_transmit() tpm: use tpm_try_get_ops() in tpm-sysfs.c. tpm: remove TPM_TRANSMIT_UNLOCKED flag tpm: introduce tpm_chip_start() and tpm_chip_stop() tpm: take TPM chip power gating out of tpm_transmit() tpm: remove @flags from tpm_transmit() drivers/char/tpm/tpm-chip.c | 107 +++++++++++- drivers/char/tpm/tpm-dev-common.c | 45 ++++- drivers/char/tpm/tpm-interface.c | 264 ++++++------------------------ drivers/char/tpm/tpm-sysfs.c | 138 ++++++++++------ drivers/char/tpm/tpm.h | 64 +++----- drivers/char/tpm/tpm1-cmd.c | 28 +--- drivers/char/tpm/tpm2-cmd.c | 72 +++----- drivers/char/tpm/tpm2-space.c | 93 ++++++++--- drivers/char/tpm/tpm_i2c_atmel.c | 5 +- drivers/char/tpm/tpm_vtpm_proxy.c | 12 +- drivers/char/tpm/xen-tpmfront.c | 2 +- 11 files changed, 407 insertions(+), 423 deletions(-)