From patchwork Sat Feb 13 13:47:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 582399 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 6224E140B04 for ; Sun, 14 Feb 2016 00:47:52 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1aUaY7-0004Ea-2N; Sat, 13 Feb 2016 13:47:47 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1aUaY6-0004EV-4i for tpmdd-devel@lists.sourceforge.net; Sat, 13 Feb 2016 13:47:46 +0000 X-ACL-Warn: Received: from mga02.intel.com ([134.134.136.20]) by sog-mx-2.v43.ch3.sourceforge.com with esmtp (Exim 4.76) id 1aUaY5-00030y-AY for tpmdd-devel@lists.sourceforge.net; Sat, 13 Feb 2016 13:47:46 +0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP; 13 Feb 2016 05:47:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,440,1449561600"; d="scan'208";a="47401730" Received: from mlynch2-mobl3.ger.corp.intel.com (HELO localhost) ([10.252.19.31]) by fmsmga004.fm.intel.com with ESMTP; 13 Feb 2016 05:47:36 -0800 From: Jarkko Sakkinen To: Peter Huewe , Marcel Selhorst , David Howells Date: Sat, 13 Feb 2016 15:47:07 +0200 Message-Id: <1455371228-20431-5-git-send-email-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1455371228-20431-1-git-send-email-jarkko.sakkinen@linux.intel.com> References: <1455371228-20431-1-git-send-email-jarkko.sakkinen@linux.intel.com> X-Spam-Score: -0.1 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.1 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1aUaY5-00030y-AY Cc: jmorris@namei.org, stable@vger.kernel.org, open list , "moderated list:TPM DEVICE DRIVER" , Harald Hoyer Subject: [tpmdd-devel] [PATCH v2 4/4] tpm_eventlog.c: fix binary_bios_measurements 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 From: Harald Hoyer The commit 0cc698af36ff ("vTPM: support little endian guests") copied the event, but without the event data, did an endian conversion on the size and tried to output the event data from the copied version, which has only have one byte of the data, resulting in garbage event data. [jarkko.sakkinen@linux.intel.com: minor coding style fixes] Signed-off-by: Harald Hoyer Fixes: 0cc698af36ff ("vTPM: support little endian guests") cc: stable@vger.kernel.org --- drivers/char/tpm/tpm_eventlog.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c index bd72fb0..6011751 100644 --- a/drivers/char/tpm/tpm_eventlog.c +++ b/drivers/char/tpm/tpm_eventlog.c @@ -242,9 +242,15 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v) temp_event.event_type = do_endian_conversion(event->event_type); temp_event.event_size = do_endian_conversion(event->event_size); - tempPtr = (char *)&temp_event; + tempPtr = (char *) &temp_event; - for (i = 0; i < sizeof(struct tcpa_event) + temp_event.event_size; i++) + for (i = 0; i < sizeof(struct tcpa_event)-1 ; i++) + seq_putc(m, tempPtr[i]); + + tempPtr = (char *) v; + + for (i = sizeof(struct tcpa_event) - 1; + i < sizeof(struct tcpa_event) + temp_event.event_size; i++) seq_putc(m, tempPtr[i]); return 0;