From patchwork Fri Jun 15 12:18:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Schwarzmeier X-Patchwork-Id: 10466325 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 70FE8603B4 for ; Fri, 15 Jun 2018 12:44:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67D1728D64 for ; Fri, 15 Jun 2018 12:44:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C75028D94; Fri, 15 Jun 2018 12:44:02 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E148228D64 for ; Fri, 15 Jun 2018 12:44:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755850AbeFOMoB (ORCPT ); Fri, 15 Jun 2018 08:44:01 -0400 Received: from smtp2.infineon.com ([217.10.52.18]:54660 "EHLO smtp2.infineon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754760AbeFOMoA (ORCPT ); Fri, 15 Jun 2018 08:44:00 -0400 X-Greylist: delayed 570 seconds by postgrey-1.27 at vger.kernel.org; Fri, 15 Jun 2018 08:44:00 EDT DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=infineon.com; i=@infineon.com; q=dns/txt; s=IFXMAIL; t=1529066640; x=1560602640; h=from:to:cc:subject:date:message-id:mime-version; bh=dRmGfiDeNg9l5z2znZE7t7hCV6www/C4Au+XEi2WXlc=; b=ZPK5/pAcSKR+iUwkf3IlUMpZJqYtLmVZrdzYGLwu+K4Ew3i9gtN3+H0z Yl2tfiT/A1cCiz9/3eGtDGiZ+98q/jcK+oN5tvqCsVVssRNzgLqIqUhHM DxYDr/oqW7+XBncMl8603XZD82vM0BsS5rN+frGEO0aEtRk5QCbr4/kZ8 o=; X-SBRS: None X-IronPort-AV: E=McAfee;i="5900,7806,8924"; a="68647770" X-IronPort-AV: E=Sophos;i="5.51,226,1526335200"; d="scan'208";a="68647770" Received: from unknown (HELO mucxv002.muc.infineon.com) ([172.23.11.17]) by smtp2.infineon.com with ESMTP/TLS/AES256-GCM-SHA384; 15 Jun 2018 14:34:29 +0200 Received: from MUCSE707.infineon.com (MUCSE707.infineon.com [172.23.7.81]) by mucxv002.muc.infineon.com (Postfix) with ESMTPS; Fri, 15 Jun 2018 14:34:29 +0200 (CEST) Received: from MUCSE716.infineon.com (172.23.7.67) by MUCSE707.infineon.com (172.23.7.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1466.3; Fri, 15 Jun 2018 14:34:28 +0200 Received: from schwaric-VirtualBox.agb.infineon.com (172.23.8.247) by MUCSE716.infineon.com (172.23.7.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1466.3; Fri, 15 Jun 2018 14:34:29 +0200 From: Ricardo Schwarzmeier To: CC: , , , , , Ricardo Schwarzmeier Subject: [PATCH] tpm: Return the actual size when receiving an unsupported command Date: Fri, 15 Jun 2018 14:18:21 +0200 Message-ID: <20180615121821.23376-1-Ricardo.Schwarzmeier@infineon.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [172.23.8.247] X-ClientProxiedBy: MUCSE707.infineon.com (172.23.7.81) To MUCSE716.infineon.com (172.23.7.67) Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The command size is computed for the header anyway. It can as well indicate the correct number of bytes to read from the driver. Signed-off-by: Ricardo Schwarzmeier --- drivers/char/tpm/tpm-interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index e32f6e85dc6d..0923e81505a5 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -423,7 +423,7 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip, header->tag = cpu_to_be16(TPM2_ST_NO_SESSIONS); header->return_code = cpu_to_be32(TPM2_RC_COMMAND_CODE | TSS2_RESMGR_TPM_RC_LAYER); - return bufsiz; + return header->length; } if (bufsiz > TPM_BUFSIZE)