Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp3564011rdb; Wed, 27 Dec 2023 11:22:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/xq+5bANFFiVh5UqHSGnPSVVMAw12qyW4d7UWxpfU7AGvRaa7LML8MbXc14gdkejs2/IY X-Received: by 2002:a17:902:a3cf:b0:1d4:2ebf:66eb with SMTP id q15-20020a170902a3cf00b001d42ebf66ebmr10127898plb.81.1703704939898; Wed, 27 Dec 2023 11:22:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703704939; cv=none; d=google.com; s=arc-20160816; b=MqIdJl/eYElvbWXSGLeaC7SE7xo4E8KSoqZsWg74GCp/PoZB21GEvCA/l5ed5Q38gr r4jHAZlYImemM+O89AiqzfuK3o58IHRwHuBevkgFpU2HsXUldoh0SSXMW/GXa6+BETpx bYTH2GtqRgwrev3IYXWmzkutdaZJjkBYhcM3dy+upwDWw5oAOkd97/jK+EYgecBdGw/O U1WXuVIku5bXvfLieo7u9wXnLgi8Lomcq63jNW0AXhkGOuUIq2rvsUbCex3XlTMsbSb9 VP3wmAW1o6Dwk7bl9RrgWJq43vjs2x6cftXT7YrALq0GR0aWr0cFcD2RZWz+JiAaEL2C T1pw== ARC-Message-Signature: i=1; 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=18f/gr/PZcXdeMM5kpAIhPR02z3c/KDZi/eOcuzIIpQ=; fh=wU8A2+/waTf10zMll2joUpZVGhjWoN9bNmcQLXOEuOY=; b=WocK4ZY/H+BRD4beRyXL7PYD7muMEbQzvk84vymn0tdzzphjYP4OIQx+F51yTPw5Qn UipnchY/quKmOt/LIUYzie8IJoFA06ERqnGALtQhAWdwd4DEKcnP5A8SB483hC9kEP0v cHTaSmIbS+0dyw5qozdMLFa7Uknqp/BC5llKXHcqr8+YOom7Leg9MRRCsXSS4cHaD0iM GO4FGiQQ1ig+CVgAoJWfjcn/LzYOPaRbKZIzM5hbxEJMrKJHBQIMPadwAqbaYhVQ9MhK neFuTYLmWFPMwoLltMQpuJo+Utgdhe/H7d7Kvz5UQ1Roooomjo9EEfwvxoYVa1ZAo3gg 36kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=bVtsB3an; spf=pass (google.com: domain of linux-nfs+bounces-825-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-nfs+bounces-825-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id g15-20020a1709029f8f00b001d3e13dc9c1si11259330plq.221.2023.12.27.11.22.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 11:22:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-825-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=bVtsB3an; spf=pass (google.com: domain of linux-nfs+bounces-825-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-nfs+bounces-825-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A8CB3B219D6 for ; Wed, 27 Dec 2023 19:22:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35F9347771; Wed, 27 Dec 2023 19:22:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="bVtsB3an" X-Original-To: linux-nfs@vger.kernel.org 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 26A1E46B85; Wed, 27 Dec 2023 19:22:06 +0000 (UTC) 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 (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BRFrDWu015987; Wed, 27 Dec 2023 19:21:24 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=18f/gr/PZcXdeMM5kpAIhPR02z3c/KDZi/eOcuzIIpQ=; b=bVtsB3annBIu4X6srNn88R2Vl4YR8tkm/MkIDQOt+CJnjUudlHDyvvtuYUnkqLxa6Y4K VrtdgWWkDpNwGFkQ/DdUqkL/EbmNwifBK+8TkMaPTUvSGhAG2bkMa7iUk74lWbLfeNo1 Rbu9Rf1wPuB8Ves/aRY+oPoa2u54fwch5e5cOpn1MFlXn1mZg90QPfsvH2pzC6MR/IIv 9Ob8WYFq2s8cORaUzVWSo9Np2P8zq2IVmRPXmt2HfvLVXfFg5CF/G0O9V00Y5FAF7omV +rV4EUw/YFbCa7pFwWLpD1aR0GueZPwEIAyb30YHEX0qAXiYSaOhW0dxN+tSsQL+1Q8U tQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3v8pxvkj0g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Dec 2023 19:21:24 +0000 Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3BRJDXvQ032429; Wed, 27 Dec 2023 19:21:23 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 3v8pxvkj07-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Dec 2023 19:21:23 +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 3BRGAZE4008402; Wed, 27 Dec 2023 19:21:22 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3v69vsv4r7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Dec 2023 19:21:22 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3BRJLLSj61866258 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Dec 2023 19:21:21 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1AC475805D; Wed, 27 Dec 2023 19:21:21 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A90C758052; Wed, 27 Dec 2023 19:21:19 +0000 (GMT) Received: from li-f45666cc-3089-11b2-a85c-c57d1a57929f.ibm.com (unknown [9.61.140.144]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 27 Dec 2023 19:21:19 +0000 (GMT) Message-ID: <96f82924cd2fda95f0c89341215e128419bf77fd.camel@linux.ibm.com> Subject: Re: [PATCH v8 23/24] ima: Make it independent from 'integrity' LSM From: Mimi Zohar To: Roberto Sassu , 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 Date: Wed, 27 Dec 2023 14:21:18 -0500 In-Reply-To: References: <20231214170834.3324559-1-roberto.sassu@huaweicloud.com> <20231214170834.3324559-24-roberto.sassu@huaweicloud.com> <5aa5986266c3a3f834114a835378455cbbff7b64.camel@linux.ibm.com> Content-Type: text/plain; charset="ISO-8859-15" X-Mailer: Evolution 3.28.5 (3.28.5-22.el8) Precedence: bulk X-Mailing-List: linux-nfs@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: ZuI2XL95XsmBzpGslmSc2WJbPjAOR3zJ X-Proofpoint-ORIG-GUID: 96PxLxuOz0BBu8l6Y97vO_NKje96XAZy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-27_12,2023-12-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 priorityscore=1501 suspectscore=0 spamscore=0 bulkscore=0 mlxscore=0 impostorscore=0 mlxlogscore=932 malwarescore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312270142 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. 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 >