Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1715687ybv; Thu, 6 Feb 2020 08:35:22 -0800 (PST) X-Google-Smtp-Source: APXvYqzEkoJcPqFXZU7Pqk5qBEINQPxbA5l2tP7EztaNtOY1+cA3bVZ6unl+635jhCiuG4deyiff X-Received: by 2002:a54:4896:: with SMTP id r22mr7599586oic.30.1581006922074; Thu, 06 Feb 2020 08:35:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581006922; cv=none; d=google.com; s=arc-20160816; b=xoVmdKitNR5a2vUHkLSmUaNZC+nL5g7h9ZuP5HoUeqpNgUs+E6PQAXomMxG03E7gQG 0nLajNtHcu7qFAR0hd2/ZNk840KO8gAwoczJtAqhyA90tewpFQqh6vuF58e4zRnYqOm6 6qApW3Rl7J0g5SO4/tFEyHKcgFedB2je70xos4zS3gT1WOICUNzW9IdBdbXv4TPszNR1 luh6yfaKErLL89xf8Q4rtc++xEIK40g0Lr9KWM4KMnZ4TZk7CPuS4S1TtlfIHqLCuZKr j9DUgSvP+f8j9rqVK3oJER1nKE4CwZdTzHCd5QowwKtkwQyEjUjBwRFutsVuNdBDUvFy Kozg== 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=AYUcvHOcB4NzGtTUYb3rMURN9/KSNr1U7dwrvzQJnEw=; b=ueJ9JreKLbDDFdsGD7HK1U2XqzIkP2T3o3iKSxl+kJWJma3OYdu41uA2SveXva6BCn pzOJbR/m8G8b9iF43Ux2D+B2h7ckrE/FzgF91YBe83nwtdf+D8uInGiE80tErqqvCbBm mRdIZs+gd+8fyiRjbyrYXJ9ZyLMvPopJ17tpZrBUJhexwYGdmK/WCXOaqzvpR56+7Rxt 6zpFZdnHwMOlxMS18visvVEdtn1C7/S5T3Qy+Xj2Ys8xN9uS9PJkfFK+f7eSXWLd67KP Vxu52L4wsd/qBTMA6xshoyzRo8+BDfuqVZslaLyLrhHPM7ByzW+pRyySv2SC9Cp0E7sn q3eQ== 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 n9si39171ota.103.2020.02.06.08.35.09; Thu, 06 Feb 2020 08:35:22 -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 S1727703AbgBFQeK (ORCPT + 99 others); Thu, 6 Feb 2020 11:34:10 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:18398 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727390AbgBFQeK (ORCPT ); Thu, 6 Feb 2020 11:34:10 -0500 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 016GX7eK058221 for ; Thu, 6 Feb 2020 11:34:09 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2y0m78vr7f-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 06 Feb 2020 11:34:07 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 6 Feb 2020 16:34:02 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 6 Feb 2020 16:33:57 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 016GXudl22216952 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 6 Feb 2020 16:33:56 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6FD234C040; Thu, 6 Feb 2020 16:33:56 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8882D4C046; Thu, 6 Feb 2020 16:33:55 +0000 (GMT) Received: from localhost.localdomain (unknown [9.85.140.59]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 6 Feb 2020 16:33:55 +0000 (GMT) Subject: Re: [PATCH v2 5/8] ima: Switch to dynamically allocated buffer for template digests 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 Date: Thu, 06 Feb 2020 11:33:54 -0500 In-Reply-To: <0b91e6977bac4cd5a638041adb3e76eb@huawei.com> References: <20200205103317.29356-1-roberto.sassu@huawei.com> <20200205103317.29356-6-roberto.sassu@huawei.com> <1581005284.5585.422.camel@linux.ibm.com> <0b91e6977bac4cd5a638041adb3e76eb@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: 8bit X-TM-AS-GCONF: 00 x-cbid: 20020616-0016-0000-0000-000002E4534F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20020616-0017-0000-0000-000033473A06 Message-Id: <1581006834.5585.430.camel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-06_01:2020-02-06,2020-02-06 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 phishscore=0 mlxscore=0 clxscore=1015 suspectscore=0 mlxlogscore=999 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002060125 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2020-02-06 at 16:27 +0000, Roberto Sassu wrote: > > -----Original Message----- > > From: Mimi Zohar [mailto:zohar@linux.ibm.com] > > Sent: Thursday, February 6, 2020 5:08 PM > > 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 > > > > Subject: Re: [PATCH v2 5/8] ima: Switch to dynamically allocated buffer for > > template digests > > > > Hi Roberto, > > > > On Wed, 2020-02-05 at 11:33 +0100, Roberto Sassu wrote: > > > This patch dynamically allocates the array of tpm_digest structures in > > > ima_alloc_init_template() and ima_restore_template_data(). The size of > > the > > > array, stored in ima_num_template_digests, is initially equal to 1 (SHA1) > > > and will be determined in the upcoming patches depending on the > > allocated > > > PCR banks and the chosen default IMA algorithm. > > > > > > Calculating the SHA1 digest is mandatory, as SHA1 still remains the default > > > hash algorithm for the measurement list. When IMA will support the > > Crypto > > > Agile format, remaining digests will be also provided. > > > > > > The position in the array of the SHA1 digest is stored in the ima_sha1_idx > > > global variable and it is determined at IMA initialization time. > > > > > > Changelog > > > > > > v1: > > > - move ima_sha1_idx to ima_crypto.c > > > - introduce ima_num_template_digests (suggested by Mimi) > > > > Instead of hardcoding "nr_allocated_banks + 1" or nr_allocated_banks + > > 2", I suggested defining "nr_allocated_banks + extra", where "extra" > > could be 0, 1, or 2. > > > > The rest of the code would remain exactly the same as you had. > > Ok. I did a small improvement. Since we determine the number of > required elements of ima_algo_array before kmalloc() I thought it > was ok to directly set that number of elements in a single variable. > > If you think that having two variables is better, I will change it. The connection to nr_allocated_banks is then not as visible.  Using two variables is clearer. Mimi