Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6463984rdb; Tue, 2 Jan 2024 02:54:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEEPromOYAqwQidFQHllSQZqtmtG+AKGvUagEoOtI0omiwOsvN1MVwobCqPbxkyLfrWTCy7 X-Received: by 2002:a17:906:d505:b0:a26:ac12:6452 with SMTP id cq5-20020a170906d50500b00a26ac126452mr3213791ejc.15.1704192878877; Tue, 02 Jan 2024 02:54:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704192878; cv=none; d=google.com; s=arc-20160816; b=1HN7VeSdGHFIvLlC7WoJYYg3R+96JSSXwXD2hd9moK8UJZNucQ0DBZF9N7XsFs+1J+ ZgMxcYb1aKJAt1sOcFIczx+l6I1lhD87swMrn1jEFy+gqLr5QvgCoi/rCvSrwA2YcxkF 7o75CFNqp5/z2NOWaLsf0WwcxMEfiJEM+EhpHDQ5N5HiVvxgUVsd3ofyYwxrfhihYu6R zP5zvqtswhbtze18HTiHwJwReDobwV7xn1HsMULMVn+1/NhQDjTDv6dnRr+HfI7mutPu NoeUxTo4zcLe0Z+7fSTC4OfYozBOgcqJ1PQAfmUKzAVYLt8tl5F7lfJDC3wGMiwVWXk1 ihog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=US373c80MJKk7DxOpsFea85s9pu2ugByUPGjl1elwLQ=; fh=DVz5JcgIgGEVWV6xYu8sJo7NG0TNq/RSBaUMbJWCvns=; b=sR5XjM9X7luczZib8el9RVnDi9EqCAHEqLlXRJUez3NKtZoYrvaKfm0vBv8vUdiG47 c1N9uK7WgPayJt2h85Ju5RxW1+73BuikuxGoA7qw0QC83FeLXmWMCpEd68i6vPb2eDIv Tlehp/WjEx842ZI0k/f52nA2S/OHf7vysDpYRCBv0WopN900zzoc6XwpZmy9rx+Gy+7L js4hUyb1yXSKgZUDqcWM6VukRm3noVxLLTKddhunoAC98Ko5cPfKFKzrAft8D07eOusA HqVONGV2+V3jRZv9j7vvmWsW1Q/e6ovdq/Kfv630tjn8FOfvVggwWe/5t0vEcF2mHWG6 S6/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs+bounces-857-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-857-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n13-20020a170906118d00b00a1c7c770507si10636525eja.286.2024.01.02.02.54.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 02:54:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-857-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; spf=pass (google.com: domain of linux-nfs+bounces-857-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-857-linux.lists.archive=gmail.com@vger.kernel.org" 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 823CE1F226CB for ; Tue, 2 Jan 2024 10:54:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 358C7DDA7; Tue, 2 Jan 2024 10:54:32 +0000 (UTC) X-Original-To: linux-nfs@vger.kernel.org Received: from frasgout12.his.huawei.com (frasgout12.his.huawei.com [14.137.139.154]) (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 27CFFD507; Tue, 2 Jan 2024 10:54:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.18.186.29]) by frasgout12.his.huawei.com (SkyGuard) with ESMTP id 4T48R00yTDz9xGZH; Tue, 2 Jan 2024 18:36:28 +0800 (CST) Received: from mail02.huawei.com (unknown [7.182.16.27]) by mail.maildlp.com (Postfix) with ESMTP id 689EF140D05; Tue, 2 Jan 2024 18:54:11 +0800 (CST) Received: from [10.48.129.192] (unknown [10.48.129.192]) by APP2 (Coremail) with SMTP id GxC2BwAnIlxD65NlVSetAw--.48730S2; Tue, 02 Jan 2024 11:54:10 +0100 (CET) Message-ID: <997cfb2f-a493-4f02-9e75-6ebb525c8406@huaweicloud.com> Date: Tue, 2 Jan 2024 11:53:50 +0100 Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v8 23/24] ima: Make it independent from 'integrity' LSM To: Mimi Zohar , viro@zeniv.linux.org.uk, brauner@kernel.org, chuck.lever@oracle.com, jlayton@kernel.org, neilb@suse.de, kolga@netapp.com, Dai.Ngo@oracle.com, tom@talpey.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, dmitry.kasatkin@gmail.com, dhowells@redhat.com, jarkko@kernel.org, stephen.smalley.work@gmail.com, eparis@parisplace.org, casey@schaufler-ca.com, shuah@kernel.org, mic@digikod.net Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-security-module@vger.kernel.org, linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, selinux@vger.kernel.org, linux-kselftest@vger.kernel.org, Roberto Sassu References: <20231214170834.3324559-1-roberto.sassu@huaweicloud.com> <20231214170834.3324559-24-roberto.sassu@huaweicloud.com> <5aa5986266c3a3f834114a835378455cbbff7b64.camel@linux.ibm.com> <96f82924cd2fda95f0c89341215e128419bf77fd.camel@linux.ibm.com> Content-Language: en-US From: Roberto Sassu In-Reply-To: <96f82924cd2fda95f0c89341215e128419bf77fd.camel@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID:GxC2BwAnIlxD65NlVSetAw--.48730S2 X-Coremail-Antispam: 1UD129KBjvJXoWxCF1xAF47CF1rZFWkGF4xXrb_yoW5AFWrpF Z7Ka4UGr1DZry2kw4vya9xZrWfK395WFW7urn0kr1kAr1vvrn0qF40kr1UuFy5Gr1Ut3WI qF4UG3sxZ3Wqy3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkjb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxV AFwI0_Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40E x7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x 0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1l42xK82IYc2Ij 64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x 8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r4a6rW5MIIYrxkI7VAKI48JMIIF0xvE 2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42 xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIE c7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07UAkuxUUUUU= X-CM-SenderInfo: purev21wro2thvvxqx5xdzvxpfor3voofrz/1tbiAgAKBF1jj5QiDQABsH On 12/27/2023 8:21 PM, Mimi Zohar wrote: > On Wed, 2023-12-27 at 17:39 +0100, Roberto Sassu wrote: >> On 12/27/2023 2:22 PM, Mimi Zohar wrote: >>> On Thu, 2023-12-14 at 18:08 +0100, Roberto Sassu wrote: >>>> From: Roberto Sassu >>>> >>>> Make the 'ima' LSM independent from the 'integrity' LSM by introducing IMA >>>> own integrity metadata (ima_iint_cache structure, with IMA-specific fields >>>> from the integrity_iint_cache structure), and by managing it directly from >>>> the 'ima' LSM. >>>> >>>> Move the remaining IMA-specific flags to security/integrity/ima/ima.h, >>>> since they are now unnecessary in the common integrity layer. >>>> >>>> Replace integrity_iint_cache with ima_iint_cache in various places >>>> of the IMA code. >>>> >>>> Then, reserve space in the security blob for the entire ima_iint_cache >>>> structure, so that it is available for all inodes having the security blob >>>> allocated (those for which security_inode_alloc() was called). Adjust the >>>> IMA code accordingly, call ima_iint_inode() to retrieve the ima_iint_cache >>>> structure. Keep the non-NULL checks since there can be inodes without >>>> security blob. >>> >>> Previously the 'iint' memory was only allocated for regular files in >>> policy and were tagged S_IMA. This patch totally changes when and how >>> memory is being allocated. Does it make sense to allocate memory at >>> security_inode_alloc()? Is this change really necessary for making IMA >>> a full fledged LSM? >> >> Good question. I think it wouldn't be necessary, we can reuse the same >> approach as in the patch 'integrity: Switch from rbtree to LSM-managed >> blob for integrity_iint_cache'. > > Going forward with the v8 proposed solution would require some real > memory usage analysis for different types of policies. > > To me the "integrity: Switch from rbtree to LSM-managed blob for > integrity_iint_cache" makes a lot more sense. Looking back at the > original thread, your reasons back then for not directly allocating the > integrity_iint_cache are still valid for the ima_iint_cache structure. Uhm, ok. It should not be too difficult to restore the old mechanism for ima_iint_cache. Will do it in v9. Thanks Roberto > Mimi > >>> >>>> >>>> Don't include the inode pointer as field in the ima_iint_cache structure, >>>> since the association with the inode is clear. Since the inode field is >>>> missing in ima_iint_cache, pass the extra inode parameter to >>>> ima_get_verity_digest(). >>>> >>>> Finally, register ima_inode_alloc_security/ima_inode_free_security() to >>>> initialize/deinitialize the new ima_iint_cache structure (before this task >>>> was done by iint_init_always() and iint_free()). Also, duplicate >>>> iint_lockdep_annotate() for the ima_iint_cache structure, and name it >>>> ima_iint_lockdep_annotate(). >>>> >>>> Signed-off-by: Roberto Sassu >> >