Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2950893rdb; Tue, 26 Dec 2023 10:16:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IERv3UHoNcrvxjTk56u8geu80TeZ5g8tZl/+y2IwCQzlnW7UFGIVLIeOjvmLxtJeaSnliVd X-Received: by 2002:a05:6a00:2af:b0:6d9:93f1:dfe1 with SMTP id q15-20020a056a0002af00b006d993f1dfe1mr2386380pfs.5.1703614566519; Tue, 26 Dec 2023 10:16:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703614566; cv=none; d=google.com; s=arc-20160816; b=nOgpiWW4o72eHjvtaNYQpAg+lINj1w9Agkqt1SS/Zg1vhw2tUi7TyNEY9KfIbYOSWR v24oeB0Be7FZtWs7cyUt2hEbplpLWLCIdo3npq39DMkrqTCzeSorUtIFPLR/LegJ8KRa 5+GThSH7oRlz+4fDzCPZ71O5us6/c6AwwusUvBSc+51EHRHqXuFzFDewEVK/igZxI9Ey q/ia4SvF76sMTkbXZBbcT84jmaghAXP6Llrlh/UeSrwk79Ex3I1l+zpa5jPwX0bDpIuG 7ULrQMHBje1b5nL0Uy3C3Na0CRLmpZrRQ9HOooHoq8Dp2jsr1SgzIXdq3+mbfWMpED30 YSVw== 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=5dBZDtb+K1DCgJH8DDLwaveoKzmRMAvBcJFK+/Jtf5I=; fh=wU8A2+/waTf10zMll2joUpZVGhjWoN9bNmcQLXOEuOY=; b=QUlAahEAt4xnk2rJ82bDM3gofZI3H9V11uZVCeTLPOLI5Vd4CfT1CkStVQh5mS3LYW fXjBFhfgRkNAVAWLZqqCrCRLCrFESwpWlM5N4GUKKAl550hxJBDP2xtb7RHuWcwCTaAI Dfw7oJvouHYuCDT5bzlz6GLnGtUGYUjRpXIKGUfCVurLR8bH/g0XWqGV3EvJFarrBaKw dt9dpSfDtxkgQn6XOFWhI6EULnlNaDN94ZEAepKlJ7tTI4NN1gOM2oHE7+JYpp0gCTXc C6YMSL4tR5poZoBbeoYWSLLIcazHggo4wMF1FN2ibbLc5t7jnbjORL0QrX8gLZPBgEit R3mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=tBE7JHBp; spf=pass (google.com: domain of linux-nfs+bounces-811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-811-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t21-20020a63f355000000b005c278210f82si9773284pgj.544.2023.12.26.10.16.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 10:16:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=tBE7JHBp; spf=pass (google.com: domain of linux-nfs+bounces-811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-811-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2B8D92827EC for ; Tue, 26 Dec 2023 18:16:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ADEC4524C4; Tue, 26 Dec 2023 18:15:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="tBE7JHBp" 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 E612250255; Tue, 26 Dec 2023 18:15:56 +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 3BQHdFUH022692; Tue, 26 Dec 2023 18:14:58 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=5dBZDtb+K1DCgJH8DDLwaveoKzmRMAvBcJFK+/Jtf5I=; b=tBE7JHBpq71tQ+K3ym4xn3RtzQBOmFL5vykkg3ijEoZnJWRpIzBB05XEzLUG/EvBmcGd kCA0+HxQBZ+QewvZdCsfDqA1pqQ5D1lxGoN74Q4jrJOQ0iSZGO+LJujHjAuUcabL/0j5 0jrPPUW0IGLT0elmfgWCiT/n+9xmppNESTdzSkyZlwXACm32VMVYs6uz/G80QU0C5vrv 0RztzkLhkCgm4iqu/qAF1H6wCC7Yo/5tGnsEfDBE6wnlg2i84vs3rK3UMGFFNmOajb/b eeN0ZSaKE9zmqbzNp0aKmeS0Y50VgVjnTc700t//qaPX17AKGdRPU6phl4U6AOabA0y9 xg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3v6y4ssehr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Dec 2023 18:14:57 +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 3BQIDaSr006127; Tue, 26 Dec 2023 18:14:56 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3v6y4ssehh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Dec 2023 18:14:56 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3BQGW7Mb016594; Tue, 26 Dec 2023 18:14:55 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3v6c3jwkab-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Dec 2023 18:14:55 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3BQIEspK16450192 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Dec 2023 18:14:54 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 29A6A58055; Tue, 26 Dec 2023 18:14:54 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B8A4858043; Tue, 26 Dec 2023 18:14:52 +0000 (GMT) Received: from li-f45666cc-3089-11b2-a85c-c57d1a57929f.ibm.com (unknown [9.61.184.58]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 26 Dec 2023 18:14:52 +0000 (GMT) Message-ID: Subject: Re: [PATCH v8 19/24] ima: Move to LSM infrastructure 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: Tue, 26 Dec 2023 13:14:52 -0500 In-Reply-To: <20231214170834.3324559-20-roberto.sassu@huaweicloud.com> References: <20231214170834.3324559-1-roberto.sassu@huaweicloud.com> <20231214170834.3324559-20-roberto.sassu@huaweicloud.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: pT8fJVabVdrbFwkeTKU5Il3CfFkW_KRY X-Proofpoint-ORIG-GUID: yVmeWBPZBscIZbs1SjyEsPPoKK6xZjsl 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-26_10,2023-12-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 suspectscore=0 spamscore=0 clxscore=1011 phishscore=0 mlxlogscore=999 bulkscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312260138 On Thu, 2023-12-14 at 18:08 +0100, Roberto Sassu wrote: > From: Roberto Sassu > > Move hardcoded IMA function calls (not appraisal-specific functions) from > various places in the kernel to the LSM infrastructure, by introducing a > new LSM named 'ima' (at the end of the LSM list and always enabled like > 'integrity'). > > Having IMA before EVM in the Makefile is sufficient to preserve the > relative order of the new 'ima' LSM in respect to the upcoming 'evm' LSM, > and thus the order of IMA and EVM function calls as when they were > hardcoded. > > Make moved functions as static (except ima_post_key_create_or_update(), > which is not in ima_main.c), and register them as implementation of the > respective hooks in the new function init_ima_lsm(). > > A slight difference is that IMA and EVM functions registered for the > inode_post_setattr, inode_post_removexattr, path_post_mknod, > inode_post_create_tmpfile, inode_post_set_acl and inode_post_remove_acl > won't be executed for private inodes. Since those inodes are supposed to be > fs-internal, they should not be of interest of IMA or EVM. The S_PRIVATE > flag is used for anonymous inodes, hugetlbfs, reiserfs xattrs, XFS scrub > and kernel-internal tmpfs files. > > Conditionally register ima_post_path_mknod() if CONFIG_SECURITY_PATH is > enabled, otherwise the path_post_mknod hook won't be available. Up to this point, enabling CONFIG_SECURITY_PATH was not required. By making it conditional on CONFIG_SECURITY_PATH, anyone enabling IMA will also need to enable CONFIG_SECURITY_PATH. Without it, new files will not be tagged as a "new" file. Casey, Paul, how common is it today not to enable CONFIG_SECURITY_PATH? Will enabling it just for IMA be a problem? > > Also, conditionally register ima_post_key_create_or_update() if > CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS is enabled. > > Move integrity_kernel_module_request() to IMA and name it > ima_kernel_module_request(), as only appraisal is affected by the crypto > subsystem trying to load kernel modules. Conditionally register > ima_kernel_module_request() if CONFIG_INTEGRITY_ASYMMETRIC_KEYS is > enabled. The previous version was so clean. Moving integrity_kernel_module_request() to IMA should be a separate patch, probably a prereq. Then like the other functions convert it to an LSM hook. Please include a line explaning why the original EVM signature is not affected. > > Finally, add the LSM_ID_IMA case in lsm_list_modules_test.c. > > Signed-off-by: Roberto Sassu > Acked-by: Chuck Lever -- thanks, Mimi