From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A27BC169C4 for ; Thu, 31 Jan 2019 18:35:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E45192086C for ; Thu, 31 Jan 2019 18:35:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725777AbfAaSfg (ORCPT ); Thu, 31 Jan 2019 13:35:36 -0500 Received: from mga18.intel.com ([134.134.136.126]:60281 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725730AbfAaSfg (ORCPT ); Thu, 31 Jan 2019 13:35:36 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jan 2019 10:35:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,545,1539673200"; d="scan'208,223";a="112698730" Received: from rkazants-mobl.ccr.corp.intel.com (HELO localhost) ([10.249.254.212]) by orsmga006.jf.intel.com with ESMTP; 31 Jan 2019 10:35:31 -0800 Date: Thu, 31 Jan 2019 20:35:31 +0200 From: Jarkko Sakkinen To: Linus Torvalds , tomas.winkler@intel.com Cc: Jason Gunthorpe , James Bottomley , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, Linux List Kernel Mailing Subject: Re: Getting weird TPM error after rebasing my tree to security/next-general Message-ID: <20190131183530.GA27112@linux.intel.com> References: <20190122010218.GA26713@linux.intel.com> <20190122025836.GH25163@ziepe.ca> <20190122132910.GA2720@linux.intel.com> <20190123153638.GA8727@linux.intel.com> <20190129132016.GA1602@linux.intel.com> <20190131122606.GA12470@linux.intel.com> <20190131160437.GA5629@linux.intel.com> <20190131170603.GA18349@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="YiEDa0DAkWCtVeE4" Content-Disposition: inline In-Reply-To: <20190131170603.GA18349@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org --YiEDa0DAkWCtVeE4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jan 31, 2019 at 07:06:03PM +0200, Jarkko Sakkinen wrote: > Found something that *does* fix the issue. If I replace memcpy_*io() > calls with regular memcpy(), the driver works and all my tests pass. OK, so the length of the response is not trashed, but only the error code. The attached patch fully fixes the issue. Here's the header again: struct tpm_output_header { __be16 tag; __be32 length; __be32 return_code; } __packed; The first to fields *are* read correctly and the last field get 1's (thus TPM error -1). With the attached the patch things work properly, but still unsatisfactory fix (return to old behavior because it seems to work). /Jarkko --YiEDa0DAkWCtVeE4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-tpm-tpm_crb-Revert-to-memcpy-for-copying-tail-of-the.patch" >From 8ff7eb66e1dc05daf1319bf8365e5a3434a90061 Mon Sep 17 00:00:00 2001 From: Jarkko Sakkinen Date: Thu, 31 Jan 2019 20:16:00 +0200 Subject: [PATCH] tpm/tpm_crb: Revert to memcpy() for copying tail of the response Revert the behavior before 170d13ca3a2f. Signed-off-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_crb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c index 36952ef98f90..003923ea50d2 100644 --- a/drivers/char/tpm/tpm_crb.c +++ b/drivers/char/tpm/tpm_crb.c @@ -299,7 +299,7 @@ static int crb_recv(struct tpm_chip *chip, u8 *buf, size_t count) if (expected > count || expected < 6) return -EIO; - memcpy_fromio(&buf[6], &priv->rsp[6], expected - 6); + memcpy(&buf[6], &priv->rsp[6], expected - 6); return expected; } -- 2.19.1 --YiEDa0DAkWCtVeE4--