Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3718945ybl; Mon, 27 Jan 2020 09:07:42 -0800 (PST) X-Google-Smtp-Source: APXvYqz3sTWsxGl4mqU2hGAPGkV46KgyjcQBtYhIDJ9u11l771wkPGPBl1Gqcwp7HDY42ufiTEuz X-Received: by 2002:a9d:7dc9:: with SMTP id k9mr13186001otn.117.1580144862651; Mon, 27 Jan 2020 09:07:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580144862; cv=none; d=google.com; s=arc-20160816; b=d1vQ8aHlCFe7BrjTh34+ri0srnLeAZr1ABd/OszHqDuAORV4LNBJXJFsTwbqHFglIe Tc9wH3bKohn3SG+H58BWhdObG2HPNRf7jnCNB2w+Dvgsb/8iOMTigb1cc/imOuqAMzna S6TPnFNtbomZvdcepOwG4aLbMqQ2y7Qcl57c3UvOI5X9VMddrCuy2V/F3ebCeh2gg7eb yhEdblEEoLxEr/gpQV/uQJ40jTe1Dsg+40kC5wmlsPlGCgaLrQyJAsZ8brozh4aqRm5i 2AqQRP6fKXd6qKYLA2SFq3t7KNTAeGkDLd9kixT4oNaJ/77KOeUecN5VyTLNs+/GAjl0 drWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=y1Xh+yb6NuFVq6BT4bfEj1YtwCIk0Jaa1fZ11/KYlgQ=; b=MrBl36wDnVVP8wNaIexbckLBwN7eks76l/SrNXI6KLvPXerk5fZ0qU580Sh18HVMnV c1g8jQcafkTwaSyvdabPeKKkqCDJQ9K8K7H9pkvwtMcPFI8Srp5qGDaHzwZkhnnVJPLq 0IPuH3Lmf5iuxINnNdNoEdQH9v3tH/I4JkFB1l+DpJC50lW9p8e4yDhwM+tTEBDrv5S6 vfqQYkjBM1okZM1bOm09K0jEmnO2Uqr6ly7815VjIh90RQbkWaWuKDLsz73EtzxWBq/Z t7zIVfHNsCz1n2l4FX971Bjjr4QhxT8XQ8VeFQImq50X5hW/fQV2MWP6WsvEa3GKdGSI jHDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h7si6362219otm.165.2020.01.27.09.07.29; Mon, 27 Jan 2020 09:07:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726725AbgA0RGP (ORCPT + 99 others); Mon, 27 Jan 2020 12:06:15 -0500 Received: from lhrrgout.huawei.com ([185.176.76.210]:2301 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725845AbgA0RGP (ORCPT ); Mon, 27 Jan 2020 12:06:15 -0500 Received: from LHREML710-CAH.china.huawei.com (unknown [172.18.7.106]) by Forcepoint Email with ESMTP id B982F9C7A7F77069A018; Mon, 27 Jan 2020 17:06:13 +0000 (GMT) Received: from roberto-HP-EliteDesk-800-G2-DM-65W.huawei.com (10.204.65.160) by smtpsuk.huawei.com (10.201.108.33) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 27 Jan 2020 17:06:03 +0000 From: Roberto Sassu To: , , , CC: , , , Roberto Sassu Subject: [PATCH 1/8] tpm: initialize crypto_id of allocated_banks to HASH_ALGO__LAST Date: Mon, 27 Jan 2020 18:04:36 +0100 Message-ID: <20200127170443.21538-2-roberto.sassu@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200127170443.21538-1-roberto.sassu@huawei.com> References: <20200127170443.21538-1-roberto.sassu@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.204.65.160] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org chip->allocated_banks contains the list of TPM algorithm IDs of allocated PCR banks. It also contains the corresponding ID of the crypto subsystem, so that users of the TPM driver can calculate a digest for a PCR extend operation. However, if there is no mapping between TPM algorithm ID and crypto ID, the crypto_id field in chip->allocated_banks remains set to zero (the array is allocated and initialized with kcalloc() in tpm2_get_pcr_allocation()). Zero should not be used as value for unknown mappings, as it is a valid crypto ID (HASH_ALGO_MD4). This patch initializes crypto_id to HASH_ALGO__LAST. Signed-off-by: Roberto Sassu --- drivers/char/tpm/tpm2-cmd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c index 13696deceae8..760329598b99 100644 --- a/drivers/char/tpm/tpm2-cmd.c +++ b/drivers/char/tpm/tpm2-cmd.c @@ -525,6 +525,8 @@ static int tpm2_init_bank_info(struct tpm_chip *chip, u32 bank_index) return 0; } + bank->crypto_id = HASH_ALGO__LAST; + return tpm2_pcr_read(chip, 0, &digest, &bank->digest_size); } -- 2.17.1