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=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 20E9CC46499 for ; Fri, 5 Jul 2019 17:52:21 +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 6BA0C20989 for ; Fri, 5 Jul 2019 17:52:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6BA0C20989 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 45gMqk0mnlzDqgl for ; Sat, 6 Jul 2019 03:52:18 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.intel.com (client-ip=134.134.136.65; helo=mga03.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 mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 45gMnq4fBJzDqf9 for ; Sat, 6 Jul 2019 03:50:37 +1000 (AEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Jul 2019 10:50:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,455,1557212400"; d="scan'208";a="175559214" Received: from hsolima-mobl1.ger.corp.intel.com ([10.252.48.252]) by orsmga002.jf.intel.com with ESMTP; 05 Jul 2019 10:50:28 -0700 Message-ID: <1270cd6ab2ceae1ad01e4b83b75fc4c6fc70027d.camel@linux.intel.com> Subject: Re: [PATCH] tpm: fixes uninitialized allocated banks for IBM vtpm driver From: Jarkko Sakkinen To: Nayna , Stefan Berger , Nayna Jain , linux-integrity@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Fri, 05 Jul 2019 20:50:27 +0300 In-Reply-To: <164b9c6e-9b6d-324d-9df8-d2f7d1ac8cfc@linux.vnet.ibm.com> References: <1562211121-2188-1-git-send-email-nayna@linux.ibm.com> <1998ebcf-1521-778f-2c80-55ad2c855023@linux.ibm.com> <164b9c6e-9b6d-324d-9df8-d2f7d1ac8cfc@linux.vnet.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 Fri, 2019-07-05 at 11:32 -0400, Nayna wrote: > I am not sure of the purpose of tpm_stop_chip(), so I have left it as it > is. Jarkko, what do you think about the change ? Stefan right. Your does not work, or will randomly work or not work depending on the chip. You need to turn the TPM on with tpm_chip_start() and turn it off with tpm_chip_stop() once you are done. This is done in tpm_chip_register() before calling tpm_auto_startup(). TPM power management was once in tpm_transmit() but not anymore after my patch set that removed nested tpm_transmit() calls. While you're on it please take into account my earlier feedback. Also, short summary could be "tpm: tpm_ibm_vtpm: Fix unallocated banks" Some oddballs in your patch that I have to ask. if (chip->flags & TPM_CHIP_FLAG_TPM2) { rc = tpm2_get_pcr_allocation(chip); if (rc) goto out; } chip->allocated_banks = kcalloc(1, sizeof(*chip->allocated_banks), GFP_KERNEL); if (!chip->allocated_banks) { rc = -ENOMEM; goto out; } Why you don't return on site and instead jump somewhere? Also the 2nd line for kcalloc() is misaligned. out: if (rc < 0) rc = -ENODEV; This will cause a new regression i.e. you let TPM error codes through. To summarize this patch fixes one regression and introduces two completely new ones... /Jarkko`