Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp559426imu; Wed, 12 Dec 2018 23:58:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xc/n0gE8Mk/z8PouaCz8FJuFKzDTFLVn0lGgZgDv7okcTI3RE/rfNH4l8y21zWTDBahteE X-Received: by 2002:a63:9712:: with SMTP id n18mr20692147pge.295.1544687914685; Wed, 12 Dec 2018 23:58:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544687914; cv=none; d=google.com; s=arc-20160816; b=E1orfFZ6k04Stp+ockOkw2NJPX55zgVL6hNehU3ChlOWD3UJdwOaOppPnJrifjyL1c kWT5mZgtEfAtkHDCrAoYMkMcdes37DiBueKmB9xpAdH7Nz6nuLarp5iJAkpPS1ZiQaLT VlEcCVvUP76ukCEQLSWF09w60k4PC/fot+cAFeLAun8TmrbXNRRKeRiceb8z+URjM+zw FlzQ+mbNlgKPg25jHeJ7OnY29W4a9AGLM7H+7gpdsl7Im0QLZfaPSB82YATdl+IDXNo8 2KZn1KPdixiX65TnMhmxmQYsgHZcSqbHpVkz/PwhQ0zr+dUH4WcCw/nz4Q7a1xOBbaro 7h5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=HFvCbLK5hyXJ42ehjngImhys5z0llRTT35TvatFo0X4=; b=y/dXTlOLAGAbSCgjhVh1kGOsa0wi5Wle2SP89K0O49AVz8f8yR1rgW1X5OwOt5ncPJ fUou0n8SvGtVQUoTop6pxLwcuwBtfXAB7vjOUvubxdZGDHm3BTYtCYvGmoE3hbLW2yCI aStRSSCDfseyPWAG+zHkxpOi9EbBdAgNH3nPvk1TaO4Jh8v7S9HHwB7+uSUPsX1l7wzb ynGxXwMjscz8xMqpOsh3dhr+6WjR6DDH/sneFWmjygpWGR8pELV47UsjEzauz3N31PBK EEZYU17SYbAwYPaFlOtyverCllPoTAZamqLsDQJg5oH+/io5xBo0E10yNooiKkZDnkOU Lo/w== 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 bi2si971936plb.200.2018.12.12.23.58.20; Wed, 12 Dec 2018 23:58:34 -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 S1726976AbeLMH5d (ORCPT + 99 others); Thu, 13 Dec 2018 02:57:33 -0500 Received: from lhrrgout.huawei.com ([185.176.76.210]:32808 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726500AbeLMH5d (ORCPT ); Thu, 13 Dec 2018 02:57:33 -0500 Received: from LHREML711-CAH.china.huawei.com (unknown [172.18.7.108]) by Forcepoint Email with ESMTP id 1779B5AF6435B; Thu, 13 Dec 2018 07:57:30 +0000 (GMT) Received: from [10.204.65.144] (10.204.65.144) by smtpsuk.huawei.com (10.201.108.34) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 13 Dec 2018 07:57:22 +0000 Subject: Re: [PATCH v6 7/7] tpm: pass an array of tpm_bank_list structures to tpm_pcr_extend() To: Jarkko Sakkinen CC: , , , , , , References: <20181204082138.24600-1-roberto.sassu@huawei.com> <20181204082138.24600-8-roberto.sassu@huawei.com> <20181205001417.GF1233@linux.intel.com> <9d6e47d9-3b88-86f6-1b60-6652dfe8dc00@huawei.com> <20181212182734.GH6333@linux.intel.com> From: Roberto Sassu Message-ID: Date: Thu, 13 Dec 2018 08:57:17 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20181212182734.GH6333@linux.intel.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.204.65.144] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/12/2018 7:27 PM, Jarkko Sakkinen wrote: > On Thu, Dec 06, 2018 at 07:38:30PM +0100, Roberto Sassu wrote: >> On 12/5/2018 1:14 AM, Jarkko Sakkinen wrote: >>> On Tue, Dec 04, 2018 at 09:21:38AM +0100, Roberto Sassu wrote: >>>> The new tpm_bank_list structure has been preferred to the tpm_digest >>>> structure, to let the caller specify the size of the digest (which may be >>>> unknown to the TPM driver). >>> >>> Why is that? Didn't previous commit query these? >> >> Since the TPM driver pads/truncates the first digest passed by the >> caller to extend PCRs for which no digest was provided, it must know >> which amount of data it can use. It is possible that the algorithm of >> the first digest is unknown for the TPM driver, if the caller of >> tpm_pcr_extend() didn't check chip->allocated_banks. >> >> By requiring that the caller passes also the digest size, this problem >> does not arise. It seems reasonable to me to pass this information, as >> the caller calculated the digest and it should know the digest size. > > OK. I noticed something other things that look to alarming: > > 1. The function does not fail if alg_id is not found. This will go > silent. It is intentional. If alg_id is not found, the PCR is extended with the first digest passed by the caller of tpm_pcr_extend(). If no digest was provided, the PCR is extended with 0s. This is done to prevent that PCRs in unused banks are extended later with fake measurements. > 2. The function does not fail if there is a mismatch with the digest > sizes. The data passed by the caller of tpm_pcr_extend() is copied to dummy_hash, which has the maximum length. Then, tpm2_pcr_extend() takes from dummy_hash as many bytes as needed, depending on the current algorithm. Roberto > /Jarkko > -- HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Bo PENG, Jian LI, Yanli SHI