Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp127498lqc; Thu, 7 Mar 2024 12:18:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWsJuBmaEL5uooIE/z2YLXxKyu7/h7dN7+tc0Lcz1qYzwLXIR1R34wbspu1Ulb8J0UtD14OFlh1ZqjIFms2BrPVStj0NVmccSxAezjpBg== X-Google-Smtp-Source: AGHT+IHz6nPNUhYZ2Q3Ov+lWUY+oP2O9fNymULtmBhMJu/We/Pu9z1j625ya/uwvymgbdTQAqMuX X-Received: by 2002:a17:906:22d3:b0:a45:40e4:8c8 with SMTP id q19-20020a17090622d300b00a4540e408c8mr2010500eja.16.1709842695449; Thu, 07 Mar 2024 12:18:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709842695; cv=pass; d=google.com; s=arc-20160816; b=OQ+nOuWeRL0jJOShi5scLE7A/DJwIhSMyfPHEnHQ7PJRzCF2btFfzUMqO3TlR+1Us5 sg3l9rT0gUQeR1X+ia+7QO0cPJL0t4I5VxoD/LiyFYRsAkZ2R18eBlOVSFs0DHvSkNmz 2CzQht9iRAUzGWbI/iNgehqBTDRYNhF+dSuXotPXdpKJuUKLZPqupixh85BP+w9MVSQr Aex4Ei4Ua3rWw8g1EG2qxqOhr8qXpsE5RTg0+riX3GMIAFKN7HSP4pdsZpyAqlgH7I4c Iem5jp6B44KXxEGddifwOH8DGf5Xqh9CKFidzC2bZhPPo48CoY9Iwt3zQohydn4DBDz/ smCQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:date:cc:to :from:subject:message-id:dkim-signature; bh=ATyzSmY6hc2fJ6cvh377et3WJ2a2h5UtxL9G4l1VoRQ=; fh=9WX4f37OFeDQy5NbMGxdkSnKGlFw1LfIYxde3vnTOqE=; b=YB6wpC/ytLW6AOnbVoTRgvwSI+diWIv2c6CpGQDJkQRt4mZYEmSxZMVrsLnM+TOWCe 1elgeSHBgJDTmfSZw8pzcm9NfH7M660gBYD++Y1YAhg4/S1kmVXwHH85iiQ6OroKfnqU P/ffVpZNzPtacuVZY7g+pUsvTHxaGX0MzlXD/9dZ3nN6nxlTcNobwcOU1ujaBG29+S9J h4KHJ/iU18xFhfdMxJjbqhF9Delul9IUb1ZCCz058fkFUDNU+w5csDvaoywr6H8T3kw0 M6DFv2fcIplj8ChgzKeQx3UTRbuwu0PTVNVGInxUb+8XKzgHqkGEzihfnWhKK+QV06A9 /L8w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=q5E6ACEX; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-96177-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96177-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id s21-20020a508d15000000b00566471ff5efsi7296131eds.555.2024.03.07.12.18.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 12:18:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96177-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=q5E6ACEX; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-96177-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96177-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 08C361F216AB for ; Thu, 7 Mar 2024 20:18:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 06FE61386C5; Thu, 7 Mar 2024 20:18:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="q5E6ACEX" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E9F7137C5A; Thu, 7 Mar 2024 20:17:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709842680; cv=none; b=heFPavcxxNYeoi2CCILAuWJIDF5RQHu5Iz6VCFriKzOKVW7T4ppVzljJhUR1o1AsdNehAEUjIR3Lav/vsFkou45TphVejBSMHWJM6rONhvBKZHc8X5SJsG0IUb5P1ZpT32O3aIZyIJRzZ874KnKWBklP1KYJletDChZdEPFEYMQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709842680; c=relaxed/simple; bh=r/8blkKqYPsCBkHFNYcQBtfslcTcKITOwPP4iW8Ofpk=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:Mime-Version; b=Znf96/L66RbkpV0JN6fC1k15+xADtZJeb2uExLYsT7aCvkVg0kfYsScfT3YYkBCiW7vQKONtQgsM4T0HX+XvI6HeDX7MJYmfRl0tOa3dbP/QwPHw8MRO80YpZ/shQfu+5m0mz4cp6MLNfCCEeoz5B7RyQn/K5p/eEHqofCqo4E8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=q5E6ACEX; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 427K2M8n024240; Thu, 7 Mar 2024 20:17:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : mime-version : content-transfer-encoding; s=pp1; bh=ATyzSmY6hc2fJ6cvh377et3WJ2a2h5UtxL9G4l1VoRQ=; b=q5E6ACEXgJ9n/+bofQ45jHmMpHLtkGhtLV0cst3vT5nIgTpSfYbZC6VKXl298Mkhw4oH 2q6TLgx+QRApD6Md604BGN2ERxMxdWhdRQJATZUGA0hhIUQJk+phHBkWaoltLBtyGiLm svcEdbXzyznlzg5MSUTW+7vIL0681EnCyKVSBn4gGaymIc1V5DMHgjEEKG+Sm0aDNo7B 92IUOKvdI/GUzIEuTOrPB1OSxewib6zFEUmffkwDd2aHlImnQPOy3BzmUdgpwrsGRitw PDips5I7zZgVWZWjs+yK+5vvJTu1Y7JauDFritrsEkgoQvkelKJEmaSE4xyumE9tLgDO FQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wqm8ur7j1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Mar 2024 20:17:11 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 427KEjdu026733; Thu, 7 Mar 2024 20:17:10 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wqm8ur7gx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Mar 2024 20:17:10 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 427IDGK8006063; Thu, 7 Mar 2024 20:17:09 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wmeetg72m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Mar 2024 20:17:09 +0000 Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 427KH69H31523288 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 7 Mar 2024 20:17:08 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7C44258064; Thu, 7 Mar 2024 20:17:06 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D725258062; Thu, 7 Mar 2024 20:17:03 +0000 (GMT) Received: from li-5cd3c5cc-21f9-11b2-a85c-a4381f30c2f3.ibm.com (unknown [9.61.133.222]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 7 Mar 2024 20:17:03 +0000 (GMT) Message-ID: Subject: Re: [RFC][PATCH 4/8] ima: Add digest_cache_measure and digest_cache_appraise boot-time policies From: Mimi Zohar To: Roberto Sassu , corbet@lwn.net, dmitry.kasatkin@gmail.com, eric.snowberg@oracle.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, wufan@linux.microsoft.com, pbrobinson@gmail.com, zbyszek@in.waw.pl, hch@lst.de, mjg59@srcf.ucam.org, pmatilai@redhat.com, jannh@google.com, dhowells@redhat.com, jikos@kernel.org, mkoutny@suse.com, ppavlu@suse.com, petr.vorel@gmail.com, petrtesarik@huaweicloud.com, mzerqung@0pointer.de, kgold@linux.ibm.com, Roberto Sassu Date: Thu, 07 Mar 2024 15:17:03 -0500 In-Reply-To: <20240214143525.2205481-5-roberto.sassu@huaweicloud.com> References: <20240214143525.2205481-1-roberto.sassu@huaweicloud.com> <20240214143525.2205481-5-roberto.sassu@huaweicloud.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-23.el8_9) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: TfqGrkqKNzvW7VbgqMWaMNGsy172yF4L X-Proofpoint-ORIG-GUID: w_l64ZQrM3m9TfhqJDI21trE_EDpnMAA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-07_15,2024-03-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 clxscore=1015 phishscore=0 priorityscore=1501 mlxlogscore=999 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403070142 On Wed, 2024-02-14 at 15:35 +0100, Roberto Sassu wrote: > From: Roberto Sassu > > Specify the 'digest_cache_measure' boot-time policy with 'ima_policy=' in > the kernel command line The 'built-in' policies may be specified on the boot command line. Please update Subject line, to user the term "built-in" as well as here. > to add the following rule at the beginning of the > IMA policy, before other rules: Comments below... > > measure func=DIGEST_LIST_CHECK pcr=12 > > which will measure digest lists into PCR 12 (or the value in > CONFIG_IMA_DIGEST_CACHE_MEASURE_PCR_IDX). > > 'digest_cache_measure' also adds 'digest_cache=content pcr=12' to the other > measure rules, if they have a compatible IMA hook. The PCR value still > comes from CONFIG_IMA_DIGEST_CACHE_MEASURE_PCR_IDX. > > Specify 'digest_cache_appraise' to add the following rule at the beginning, > before other rules: > > appraise func=DIGEST_LIST_CHECK appraise_type=imasig|modsig > > which will appraise digest lists with IMA signatures or module-style > appended signatures. > > 'digest_cache_appraise' also adds 'digest_cache=content' to the other > appraise rules, if they have a compatible IMA hook. > > Signed-off-by: Roberto Sassu > --- > .../admin-guide/kernel-parameters.txt | 15 ++++++- > security/integrity/ima/Kconfig | 10 +++++ > security/integrity/ima/ima_policy.c | 45 +++++++++++++++++++ > 3 files changed, 69 insertions(+), 1 deletion(-) [...] > @@ -971,6 +1006,16 @@ void __init ima_init_policy(void) > { > int build_appraise_entries, arch_entries; > > + /* > + * We need to load digest cache rules at the beginning, to avoid dont_ > + * rules causing ours to not be reached. > + */ "lockdown" trusts IMA to measure and appraise kernel modules, if the rule exists. Placing the digest_cache first breaks this trust. From a trusted and secure boot perspective, the architecture specific policy rules should not be ignored. Putting the digest_cache before any other rules will limit others from being able to use digest_cache. Instead of putting the digest_cache_{measure,appraise} built-in policies first, skip loading the dont_measure_rules. Mimi > + if (ima_digest_cache_measure) > + add_rules(&measure_digest_cache_rule, 1, IMA_DEFAULT_POLICY); > + > + if (ima_digest_cache_appraise) > + add_rules(&appraise_digest_cache_rule, 1, IMA_DEFAULT_POLICY); > + > /* if !ima_policy, we load NO default rules */ > if (ima_policy) > add_rules(dont_measure_rules, ARRAY_SIZE(dont_measure_rules),