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=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 65144C46499 for ; Fri, 5 Jul 2019 10:45:38 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E065F2133F for ; Fri, 5 Jul 2019 10:45:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E065F2133F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45gBMM3Jr5zDqRW for ; Fri, 5 Jul 2019 20:45:35 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.intel.com (client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=jarkko.sakkinen@linux.intel.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45gBK6249gzDq7j for ; Fri, 5 Jul 2019 20:43:38 +1000 (AEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Jul 2019 03:42:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,454,1557212400"; d="scan'208";a="158476114" Received: from jsakkine-mobl1.tm.intel.com ([10.237.50.189]) by orsmga008.jf.intel.com with ESMTP; 05 Jul 2019 03:42:19 -0700 Message-ID: Subject: Re: [PATCH] tpm: fixes uninitialized allocated banks for IBM vtpm driver From: Jarkko Sakkinen To: Nayna Jain , linux-integrity@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Michal Suchanek Date: Fri, 05 Jul 2019 13:42:18 +0300 In-Reply-To: <1562211121-2188-1-git-send-email-nayna@linux.ibm.com> References: <1562211121-2188-1-git-send-email-nayna@linux.ibm.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.1-2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sachin Sant , George Wilson , linux-kernel@vger.kernel.org, Mimi Zohar , Jason Gunthorpe , Peter Huewe , Michal Suchanek Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Wed, 2019-07-03 at 23:32 -0400, Nayna Jain wrote: > The nr_allocated_banks and allocated banks are initialized as part of > tpm_chip_register. Currently, this is done as part of auto startup > function. However, some drivers, like the ibm vtpm driver, do not run > auto startup during initialization. This results in uninitialized memory > issue and causes a kernel panic during boot. > > This patch moves the pcr allocation outside the auto startup function > into tpm_chip_register. This ensures that allocated banks are initialized > in any case. > > Fixes: 879b589210a9 ("tpm: retrieve digest size of unknown algorithms with > PCR read") > Signed-off-by: Nayna Jain Please add Reported-by: Michal Suchanek It is missing. Michal is there a chance you could try this out once Nayna send a new version? > --- > drivers/char/tpm/tpm-chip.c | 37 +++++++++++++++++++++++++++++++++++++ > drivers/char/tpm/tpm.h | 1 + > drivers/char/tpm/tpm1-cmd.c | 12 ------------ > drivers/char/tpm/tpm2-cmd.c | 6 +----- > 4 files changed, 39 insertions(+), 17 deletions(-) > > diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c > index 8804c9e916fd..958508bb8379 100644 > --- a/drivers/char/tpm/tpm-chip.c > +++ b/drivers/char/tpm/tpm-chip.c > @@ -550,6 +550,39 @@ static int tpm_add_hwrng(struct tpm_chip *chip) > return hwrng_register(&chip->hwrng); > } > > +/* > + * tpm_pcr_allocation() - initializes the chip allocated banks for PCRs > + */ > +static int tpm_pcr_allocation(struct tpm_chip *chip) Why that name and not tpm_get_pcr_allocation()? Do not get why "get_" has been dropped. Please add it back. Would be senseful to create tpm1_get_pcr_allocation() to tpm1-cmd.c now that a new function needs to be introduced anyway. Please do it for that for TPM 1.x part. /Jarkko