Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2974445ybf; Mon, 2 Mar 2020 20:04:23 -0800 (PST) X-Google-Smtp-Source: ADFU+vv1wFzZsBBGDusST9gVHp9nZ0GX/TonOeGkkvmh7ZSvhEOWFBBEo6KZKHc9fyi47FMKOvMn X-Received: by 2002:a05:6830:1bc3:: with SMTP id v3mr2013454ota.310.1583208263490; Mon, 02 Mar 2020 20:04:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583208263; cv=none; d=google.com; s=arc-20160816; b=BguDA+6djjoD+Z5zRwG2+t9tAI7bYWlHZgUYc8/g04KVnIVM4VA3w77AcwX5k44LeS WkzwkZD+zFUWVcgw1VThqKfvQbwYXk2nUk/lbMwfvrUm0WofdSQH/+ShKbuD7yeMdSAv navuiWr6MVDk8IgSzmTbvLaXaK8IlGKyhlsYvlZB4lytxWJfSkOb/qYj92FviSUQhbiv JYrQGeeIAtPmiPkXtYMU6z3BofUaxyQC+/0Xu6NXKc35tK1xggl99zgPm4M9NuqK40gr /24w4BMqNBxnaxvQlSc7UUa9xLCnZOVp2ccqOmdh/i0ep4GQc2n7l9bqCdCLGC9Q04S7 xl8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:cc:to:from:subject; bh=Vrhq48O9Qt0k693N+7xnBBv5z4SO7SabwC6mnMCOLno=; b=UHHO8Pp3+6N5NoFEf9dxVAMVXc/48c5XeSXY3uAPwyB+kfk+nPLhJfV69DfJRhyIyb uayvdFtLoVNCTlIrqekXHUUcEExSMpEDg+aqxWe0edZSuOVogkU3p69czW2L2FpfB4dp Nkcg2TbTjQp4cV2jZlcBebWyLn4xjzvsB/rDRtH2Ip8/gjhYR77k1g72ic8keGk6dnOc d3ln8r4LQEb/SD6UMq6Vx0tiibkYxseKnCCzYxgYcPi3RXUb5KqGYcWzU3fUlR4TkNZm vgK/Aloj81Pd93UqTOHNXk+HRAXw4f8DtymBd6xLUbvJ8PuEb6mzJFau5MbuqByHHUwH BSBg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g10si7575067otn.12.2020.03.02.20.04.10; Mon, 02 Mar 2020 20:04:23 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727000AbgCCEDv (ORCPT + 99 others); Mon, 2 Mar 2020 23:03:51 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:50626 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726910AbgCCEDu (ORCPT ); Mon, 2 Mar 2020 23:03:50 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02340baI123886 for ; Mon, 2 Mar 2020 23:03:49 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2yfmqak183-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 02 Mar 2020 23:03:49 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Mar 2020 04:03:47 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 3 Mar 2020 04:03:44 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02343h1x54263954 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 3 Mar 2020 04:03:43 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7928D5205F; Tue, 3 Mar 2020 04:03:43 +0000 (GMT) Received: from localhost.localdomain (unknown [9.80.229.179]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 970925204E; Tue, 3 Mar 2020 04:03:42 +0000 (GMT) Subject: Re: [PATCH v3 7/8] ima: Calculate and extend PCR with digests in ima_template_entry From: Mimi Zohar To: Roberto Sassu , James.Bottomley@HansenPartnership.com, jarkko.sakkinen@linux.intel.com Cc: linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, silviu.vlasceanu@huawei.com Date: Mon, 02 Mar 2020 23:03:42 -0500 In-Reply-To: <20200210100418.22049-1-roberto.sassu@huawei.com> References: <20200210100418.22049-1-roberto.sassu@huawei.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 20030304-0028-0000-0000-000003E03FA6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20030304-0029-0000-0000-000024A56A70 Message-Id: <1583208222.8544.168.camel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-03-02_09:2020-03-02,2020-03-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 adultscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003030028 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2020-02-10 at 11:04 +0100, Roberto Sassu wrote: > @@ -219,6 +214,8 @@ int ima_restore_measurement_entry(struct ima_template_entry *entry) > > int __init ima_init_digests(void) > { > + u16 digest_size; > + u16 crypto_id; > int i; > > if (!ima_tpm_chip) > @@ -229,8 +226,17 @@ int __init ima_init_digests(void) > if (!digests) > return -ENOMEM; > > - for (i = 0; i < ima_tpm_chip->nr_allocated_banks; i++) > + for (i = 0; i < ima_tpm_chip->nr_allocated_banks; i++) { > digests[i].alg_id = ima_tpm_chip->allocated_banks[i].alg_id; > + digest_size = ima_tpm_chip->allocated_banks[i].digest_size; > + crypto_id = ima_tpm_chip->allocated_banks[i].crypto_id; > + > + /* for unmapped TPM algorithms digest is still a padded SHA1 */ > + if (crypto_id == HASH_ALGO__LAST) > + digest_size = SHA1_DIGEST_SIZE; > + > + memset(digests[i].digest, 0xff, digest_size); Shouldn't the memset here be of the actual digest size even for unmapped TPM algorithms. > + } > > return 0; > }