Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp694334ybl; Fri, 31 Jan 2020 06:24:28 -0800 (PST) X-Google-Smtp-Source: APXvYqwZDLk8B9YgKAnBYXYKNPHRjpBHnDYmzEZspzA55sHzYEUHt31RsZ3qMukgRMmU8pmGGGRM X-Received: by 2002:a9d:6c9a:: with SMTP id c26mr7457446otr.279.1580480668326; Fri, 31 Jan 2020 06:24:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580480668; cv=none; d=google.com; s=arc-20160816; b=nSDZ5Wtp2f7Uvedi4evtCCljOWouenMYB1m8poz9fL52CqAr2X/MakY6MI2p0nB94h WpFDwbHJhC+uW7JDz8wf+phZqGhXf6/8nt2J1k/CTvza5Zme/mHIg87wy4sHlVbRpwNu 2eBSwXx3XMGdX98E1dfc3Ivssj0Wjx9WNPMKjQo2UpdzKVDNwwBccSgBCGJcPzSksl1e OPTgnkq9H6lL1BXHfCsEI3JMiuk0aU9DTUP71fKOqUmuZ6GAurGikjad6O58Zb4oRNlF vEW2h3d2VIm2HQLQCffdAIEX41A0tOD6y7vnZog+YFI/3ueKL4GlNxv96k1hzTFGI5Ap qsbw== 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=pW/jCNLW8u/PDK7eE2BVK9Bd7OZowTxPq+SSPFDEfH4=; b=RG4fQcVGpXIQiBstsd1NxM3j50asOZqga00ioWNPmGh655ehpLCJJvrT3KSWg6jLqg DgE6QYzaJOWNnB041FuY4GrKm9vqWJ16zi7OykYAJAb95rBSclsvL41fe3wSHJZFYWdR B9ELbXv3+SiW0om77J9lCwGHtOEpRXPYERUVuZrLpfVC8QnoNE/OPzob733NxHWgkrWy TR4sW8yF8n3d55zallexNhKMuZskPon2CJjqOLsz+iGHaM0JPOwPW4eBo50VYg1XXkAA udm3ZJtZr5D4oBD6rZ6pAIMQXV5n6Ov3/o+/b8JK86tIvJnJJizoDj73n4woPRexz+9C T/UA== 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 t3si1039268otp.230.2020.01.31.06.24.15; Fri, 31 Jan 2020 06:24:28 -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 S1728840AbgAaOWO (ORCPT + 99 others); Fri, 31 Jan 2020 09:22:14 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:39238 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728730AbgAaOWO (ORCPT ); Fri, 31 Jan 2020 09:22:14 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00VEGrmI022487 for ; Fri, 31 Jan 2020 09:22:13 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2xvkpaddk6-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 31 Jan 2020 09:22:12 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 31 Jan 2020 14:22:11 -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) Fri, 31 Jan 2020 14:22:07 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00VEM61T52559894 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 31 Jan 2020 14:22:06 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C9C3DA4040; Fri, 31 Jan 2020 14:22:06 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F32F7A4057; Fri, 31 Jan 2020 14:22:05 +0000 (GMT) Received: from localhost.localdomain (unknown [9.85.193.32]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 31 Jan 2020 14:22:05 +0000 (GMT) Subject: Re: [PATCH 7/8] ima: use ima_hash_algo for collision detection in the measurement list From: Mimi Zohar To: Roberto Sassu , "jarkko.sakkinen@linux.intel.com" , "james.bottomley@hansenpartnership.com" , "linux-integrity@vger.kernel.org" Cc: "linux-security-module@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Silviu Vlasceanu Date: Fri, 31 Jan 2020 09:22:05 -0500 In-Reply-To: <44c1b3f6d3fe414e914317ef8e5c6f8f@huawei.com> References: <20200127170443.21538-1-roberto.sassu@huawei.com> <20200127170443.21538-8-roberto.sassu@huawei.com> <1580423169.6104.18.camel@linux.ibm.com> <44c1b3f6d3fe414e914317ef8e5c6f8f@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: 20013114-0028-0000-0000-000003D6478B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20013114-0029-0000-0000-0000249A99D3 Message-Id: <1580480525.6104.88.camel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-31_03:2020-01-31,2020-01-31 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 mlxscore=0 impostorscore=0 phishscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1911200001 definitions=main-2001310123 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2020-01-31 at 14:02 +0000, Roberto Sassu wrote: > > -----Original Message----- > > From: linux-integrity-owner@vger.kernel.org [mailto:linux-integrity- > > owner@vger.kernel.org] On Behalf Of Mimi Zohar > > Sent: Thursday, January 30, 2020 11:26 PM > > To: Roberto Sassu ; > > jarkko.sakkinen@linux.intel.com; > > james.bottomley@hansenpartnership.com; linux-integrity@vger.kernel.org > > Cc: linux-security-module@vger.kernel.org; linux-kernel@vger.kernel.org; > > Silviu Vlasceanu > > Subject: Re: [PATCH 7/8] ima: use ima_hash_algo for collision detection in > > the measurement list > > > > On Mon, 2020-01-27 at 18:04 +0100, Roberto Sassu wrote: > > > Before calculating a digest for each PCR bank, collisions were detected > > > with a SHA1 digest. This patch includes ima_hash_algo among the > > algorithms > > > used to calculate the template digest and checks collisions on that digest. > > > > > > Signed-off-by: Roberto Sassu > > > > Definitely needed to protect against a sha1 collision attack. > > > > > > > > > > > > diff --git a/security/integrity/ima/ima_api.c > > b/security/integrity/ima/ima_api.c > > > index ebaf0056735c..a9bb45de6db9 100644 > > > --- a/security/integrity/ima/ima_api.c > > > +++ b/security/integrity/ima/ima_api.c > > > @@ -51,7 +51,7 @@ int ima_alloc_init_template(struct ima_event_data > > *event_data, > > > if (!*entry) > > > return -ENOMEM; > > > > > > - (*entry)->digests = kcalloc(ima_tpm_chip->nr_allocated_banks + 1, > > > + (*entry)->digests = kcalloc(ima_tpm_chip->nr_allocated_banks + 2, > > > sizeof(*(*entry)->digests), GFP_NOFS); > > > if (!(*entry)->digests) { > > > result = -ENOMEM; > > > > I would prefer not having to allocate and use "nr_allocated_banks + 1" > > everywhere, but I understand the need for it.  I'm not sure this patch > > warrants allocating +2.  Perhaps, if a TPM bank doesn't exist for the > > IMA default hash algorithm, use a different algorithm or, worst case, > > continue using the ima_sha1_idx. > > We could introduce a new option called ima_hash_algo_tpm to specify > the algorithm of an allocated bank. We can use this for boot_aggregate > and hash collision detection. I don't think that would work in the case where the IMA default hash is set to sha256, but the system has a TPM 1.2 chip.  We would be left using SHA1 for the file hash collision detection. With my suggestion of defining an "extra" variable, I kind of back tracked here.  There are two problems that I'm trying to address - hard coding the number of additional "banks" and unnecessarily allocating more memory than necessary.  By pre-walking the list, calculating the "extra" banks, you'll resolve both issues. Mimi