Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp815226rdb; Fri, 9 Feb 2024 01:50:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcl2h1PXFTOz+MnOn4hf7EGSXc+ImxkfDdv57XWW33OOCYlOMhIBM+bPvXlnftOSgReP4Q X-Received: by 2002:a17:906:2886:b0:a38:2ca6:5b5d with SMTP id o6-20020a170906288600b00a382ca65b5dmr745162ejd.16.1707472221633; Fri, 09 Feb 2024 01:50:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707472221; cv=pass; d=google.com; s=arc-20160816; b=yhZWWXKptjILwb8faTsscArz4bR5C38lKJ4oMigZIIlOQG3xWrP+AUEBK2YPoML/76 8yZjrRdnVf8mV1UsuZlVAGz8moRAzyNr+DVc9ZN+t4H84VqltsJY4ONSkMubokpVoNkQ H1ybzShrvtZkvZVdvTls8bnMEHu4n/08jBPc0Uakkxu46tNb41h9qRgrjTa5SeFsoQ25 08iUVHtVktq+y/g/y+9BY8dK2oNZjQbZurY/l6JbhfACQm4x5MKGFmbW+UpaRxEelJyg U1fsnzmInsjYWF9UhOkhVbO6tkGgDmY1XmZR7spIu+j2ojMcZtsLRxsAxrWvaavMtYqz 2vRw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=EJ+9bQQ2E/wMcZsioAeORALoQrSHzbl16A6zJawGMKU=; fh=jdl6oPe62ZuiBav77iAj4nUPOg39cm/soTCgTsEjEtk=; b=GPHqwFXPHpUpWcK1F/X2JFHqnD2xfLq7ZZYgSSGB0LX28EdfAyOT0JZ1j0kCjWEYRZ R1cIpBZOG7eLvvQ0YG2Eyrsf0lJrjrEAeLaoSqewxl6Mrxx50SCI+kWKsfvC27zsz16H 4gZDMT8JTA8FlrVZCCK+fj0UiBUg61f9MO/iOl+SGe6qt1/iSTkDx29pQEt84AAHHoFk pwsjQQcGP/8GRStuvaJ5qHDXlyRHBxHAWNDicnVQyjuUgDE9b38358eHjFPpiPUZimS9 9c5Sqtnb/W7V72yJ/xureLZRJT9v6jMAV3+5dCcGAYqr0POENZVhdlyezwSnXLMdEKcK 39Yw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tj23qJkh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-1874-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1874-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXeMpnOaW3/HXn3lqLaMrmcNg1JAWfNJPjat2RIQAr2xbZYSUAFHl2BVX8VXp8f2RvWOsLaDkpuYW6xUbFJLlnQEXH4fjzYzDUZc5+Aqw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id b27-20020a1709062b5b00b00a3851c2ab09si614179ejg.786.2024.02.09.01.50.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 01:50:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-1874-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tj23qJkh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-1874-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1874-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 2228F1F26C3D for ; Fri, 9 Feb 2024 09:50:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1AC9867C6C; Fri, 9 Feb 2024 09:50:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tj23qJkh" X-Original-To: linux-nfs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CFDBF66B54; Fri, 9 Feb 2024 09:50:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707472215; cv=none; b=qbjEfw6Xk1NCIi+0EDa0XncgYioj2W6s+NTAbWa1yDIkuuDx7L3TxyOEFoMuLbLtoD3WR8ZrsrIwveTkUFVbNNmWW6TjkTMYxv0g5IsNuZrK4KZJ9PVXovjED2BcUg0dgbWkVaE9WqV3uWUiTqaYqQO+zVJ8WLzff11PmgM7EtM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707472215; c=relaxed/simple; bh=p9KT0bMR+IID1hXXuOL2WksmLXvhHF8bNUuC9TAfm+0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jD7aMfJg+jSO6Xi+hkqms2kYcuruPgkUHpAbAMvFREMc+MqTEu1DqC5MFaeQMVjyMJqD89K8HOfvPZEkMoM3Uu6Ui6EOHEwEqiabbLu0erQApW5DpnvNJi3mHlhTl0W8bjD1Op4DS3JpPXWU8E08mOsdJOC9f3td6Ig94oNH+8c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tj23qJkh; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD211C433F1; Fri, 9 Feb 2024 09:50:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707472214; bh=p9KT0bMR+IID1hXXuOL2WksmLXvhHF8bNUuC9TAfm+0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tj23qJkhmVHPXUAdr5N2zoIBOtiVMhgLk0BsGvQiaIvxYCTuSQH5S327SU/teJOgP r0C/F+Xn6q3Y4FVKXDsFRskERs4mjCUAo0lYnxNtnyj2BdDkNe++YOvj6eF/ZeTVcs gQuE8h8p/mThFnYZ1WTPqCxTMpENjFZgzR1MI38U3uWpbO0w06mO0cXGIIRd+EJF+l Kh050UFuf6avm8IK9y0Mp9Up5jIWGUM26zHnw9mgZrzVO362Cl6PT0xJ7gfRoS17nN eEe1iYCUk7M3a79BYQ+vhdXO+IjG+Xazskk5yVi1oUWMOCO+d/biTL7kmxW6pPeRzo CnuniTtr224EQ== Date: Fri, 9 Feb 2024 10:50:05 +0100 From: Christian Brauner To: Roberto Sassu Cc: viro@zeniv.linux.org.uk, 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, zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, eric.snowberg@oracle.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, linux-kernel@vger.kernel.org, linux-fsdevel@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 Subject: Re: [PATCH v9 20/25] ima: Move to LSM infrastructure Message-ID: <20240209-zensor-antilopen-e6c5e64b8706@brauner> References: <20240115181809.885385-1-roberto.sassu@huaweicloud.com> <20240115181809.885385-21-roberto.sassu@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240115181809.885385-21-roberto.sassu@huaweicloud.com> On Mon, Jan 15, 2024 at 07:18:04PM +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(). > > Select CONFIG_SECURITY_PATH, to ensure that the path-based LSM hook > path_post_mknod is always available and ima_post_path_mknod() is always > executed to mark files as new, as before the move. > > 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_key_create_or_update() if > CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS is enabled. Also, conditionally register > ima_kernel_module_request() if CONFIG_INTEGRITY_ASYMMETRIC_KEYS is enabled. > > Finally, add the LSM_ID_IMA case in lsm_list_modules_test.c. > > Signed-off-by: Roberto Sassu > Acked-by: Chuck Lever > --- > fs/file_table.c | 2 - > fs/namei.c | 6 - > fs/nfsd/vfs.c | 7 -- > fs/open.c | 1 - Acked-by: Christian Brauner